thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API

Home Page:https://graphqlite.thecodingmachine.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array input

drmax24 opened this issue · comments

Do we have a simple way to define a simple array of scalars in the input handler?

Here is an example of laravel rebing/graphql query arguments.
I have an argument named ids that is an array of ids
I can easily define an array input without creating a custom input type.

    public function args(): array
    {
        return [
            'ids'                   => [
                'type' => Type::listOf(Type::int()),
            ],

Do we have anything similar?

It kinda works. But how to make ids argument to be optional?

    /**
     * @param string[] $ids
     */
    #[Query(
        name: 'groups',
        outputType: '[CommunityGroup]',
    )]
    public function resolve(?array $ids = null, int $offset = 0, int $limit = 10): \Generator

ids is not optional in graphql schema