Skip to content

[GraphQL] How to specify GraphQL types in DTO? #3422

Closed
@oleg-brizy

Description

@oleg-brizy

I am trying to solve #3420 with input class but I can't specify args types properly

/**
 * @ApiResource(
 *  graphql={
 *     "create"={
 *         "mutation"=CollectionTypeMutationResolver::class,
 *         "input"=CreateCollectionTypeInput::class
 *     }
 *   }
 * )
class CreateCollectionTypeInput
{
    /**
     * @var CollectionCategory
     */
    public $category;

    /**
     * @var array
     *
     * How to specify that this must be of type
     * [CollectionTypeFieldInput!]
     * ?
     */
    public $fields;
}

but in schema I get

category: String!
fields: Iterable!

I want Dto fields to match these args

"args"={
    "category"={"type"="ID", "description"="CollectionCategory"},
    "fields"={"type"="[CollectionTypeFieldInput!]"},
}

If I set in ApiResource both "input" and "args" then "input" is ignored (and I get error "fields must be IRIs")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions