Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 901 Bytes

input-object.md

File metadata and controls

42 lines (34 loc) · 901 Bytes

Input object

With YAML

# src/MyBundle/Resources/config/graphql/HumanAndDroid.types.yml
#
#  This implements the following type system shorthand:
#    input HeroInput {
#      name: Episode!
#   }
HeroInput:
    type: input-object
    config:
        fields:
            name:
                type: "String!"

With Annotations

Note: If the attribute name is not set on the @GQL\Input, the final name will be the class name suffixed by "Input" if it doesn't have already the suffix. (ex: If the class name is Hero the input name will be HeroInput).
With Input type, the @Field annotation on methods are ignored, so is the annotations on properties that need a resolver.

<?php

namespace AppBundle;

use Overblog\GraphQLBundle\Annotation as GQL;

/**
 * @GQL\Input
 */
class HeroInput
{
    /**
     * @GQL\Field(type="String!")
     */
    public $name;
}