All types in GraphQL are of two categories: input and output.

Obviously, NonNull and List types belong to both categories depending on their inner type.

Input objects are used for mutations or arguments for queries, in case of mutations the GraphQLBundle recommend the use of Symfony Forms for Mutation Inputs , but if you need in some special case can use input objects too.

Defining Input Objects

To define a input object must use the @GraphQL\InputObjectType()

/**
 * @GraphQL\ObjectType()
 */
class OrderBy
{

Fields and others settings are very similar to common Object Types

By default GraphQLBundle search for input objects in the Model folder and sub-folders of each bundle.

The following example demostrate the use case of input object in a query argument.

Input Object Definition:

namespace App\Model\Argument;

use Ynlo\GraphQLBundle\Annotation as GraphQL;

/**
 * @GraphQL\InputObjectType()
 */
class OrderBy
{
    /**
     * @GraphQL\Field(type="string!")
     */
    protected $field;

    /**
     * @GraphQL\Field(type="string")
     */
    protected $direction = 'ASC';
    ...

GraphQL Query

query {
  posts(first: 10, orderBy: {field: "date", direction: "ASC"}){
    ...
  }
}

In the above example the field direction is a string but can be a ENUM with 'ASC' and 'DESC' as values.