---
DateTime:
    type: custom-scalar
    config:
        description: "The DateTime type"
        serialize: ["Overblog\\GraphQLGenerator\\Tests\\DateTimeType", "serialize"]
        parseValue: ["Overblog\\GraphQLGenerator\\Tests\\DateTimeType", "parseValue"]
        parseLiteral: ["Overblog\\GraphQLGenerator\\Tests\\DateTimeType", "parseLiteral"]

# Characters in the Star Wars trilogy are either humans or droids.
#
# This implements the following type system shorthand:
#   interface Character {
#     id: String!
#     name: String
#     friends: [Character]
#     appearsIn: [Episode]
#   }
Character:
    type: interface
    config:
        description: "@='A character' ~ ' in the Star Wars Trilogy'"
        fields:
            id:
                type: "String!"
                description: "The id of the character."
            name:
                type: "String"
                description: "The name of the character."
            friends:
                type: "[Character]"
                description: "The friends of the character."
            appearsIn:
                type: "[Episode]"
                description: "Which movies they appear in."
        # used expression language to defined resolver (tagged services)
        resolveType: "Overblog\\GraphQLGenerator\\Tests\\Resolver::resolveType"

#  The other type of character in Star Wars is a droid.
#
#  This implements the following type system shorthand:
#    type Droid : Character {
#      id: String!
#      name: String
#      friends: [Character]
#      appearsIn: [Episode]
#      primaryFunction: String
#   }
Droid:
    type: object
    config:
        description: "A mechanical creature in the Star Wars universe."
        fields:
            id:
                type: "String!"
                description: "The id of the droid."
                resolve: "@=value['id']"
            name:
                type: "String"
                description: "The name of the droid."
            friends:
                type: "[Character]"
                description: "The friends of the droid, or an empty list if they have none."
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver" , "getFriends"]
            appearsIn:
                type: "[Episode]"
                description: "Which movies they appear in."
            primaryFunction:
                type: "String"
                description: "The primary function of the droid."
        interfaces: [Character]

# The original trilogy consists of three movies.
# This implements the following type system shorthand:
# enum Episode { NEWHOPE, EMPIRE, JEDI }
Episode:
    type: enum
    config:
        description: "One of the films in the Star Wars Trilogy"
        values:
            NEWHOPE:
                value: 4
                description: "Released in 1977."
            EMPIRE:
                value: 5
                description: "Released in 1980."
            JEDI:
                value: 6
                description: "Released in 1983."

# We define our human type, which implements the character interface.
#
# This implements the following type system shorthand:
#   type Human : Character {
#     id: String!
#     name: String
#     friends: [Character]
#     appearsIn: [Episode]
#   }
Human:
    type: object
    config:
        description: "A humanoid creature in the Star Wars universe."
        fields:
            id:
                type: "String!"
                description: "The id of the character."
            name:
                type: "String"
                description: "The name of the character."
            friends:
                type: "[Character]"
                description: "The friends of the character."
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver" , "getFriends"]
            appearsIn:
                type: "[Episode]"
                description: "Which movies they appear in."
            homePlanet:
                type: "String"
                description: "The home planet of the human, or null if unknown."
        interfaces: [Character]

# This is the type that will be the root of our query, and the
# entry point into our schema. It gives us the ability to fetch
# objects by their IDs, as well as to fetch the undisputed hero
# of the Star Wars trilogy, R2-D2, directly.
# This is the type that will be the root of our query, and the
# entry point into our schema.
#
# This implements the following type system shorthand:
#   type Query {
#     hero(episode: Episode): Character
#     human(id: String!): Human
#     droid(id: String!): Droid
#   }
#
Query:
    type: object
    config:
        description: "A humanoid creature in the Star Wars universe or a faction in the Star Wars saga."
        fields:
            hero:
                type: "Character"
                args:
                    episode:
                        type: "HeroInput"
                        description: |
                          If omitted, returns the hero of the whole saga.
                          If provided, returns the hero of that particular episode.
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver", "getHero"]
            human:
                type: "Human"
                args:
                    id:
                        description: "id of the human"
                        type: "String!"
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver", "getHuman"]
            droid:
                type: "Droid"
                args:
                    id:
                        description: "id of the droid"
                        type: "String!"
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver", "getDroid"]
            dateTime:
                type: "DateTime!"
                args:
                    dateTime:
                        type: "DateTime"
                resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver", "getDateTime"]

HumanAndDroid:
    type: union
    config:
        types: [Human, Droid]
        description: Human and Droid

HeroInput:
    type: input-object
    config:
        fields:
            id:
                type: "ID"
            name:
                type: "Episode"
                defaultValue: 4
