Skip to content

[Laravel/GraphQL] Custom QueryParameter, removes default args #6698

Closed
@toitzi

Description

@toitzi

API Platform version(s) affected: 4.0.3

Description
I have a User Model, and the goal is to get all users (paginated) but also beeing able to order them. To archive this i added the following to my App\Models\User:

#[ApiResource(
    operations: [
        new Get(),
        new GetCollection(
            parameters: [
                new QueryParameter(key: 'order[:property]', filter: OrderFilter::class),
            ],
        )
    ],
    graphQlOperations: [
        new Query(),
        new QueryCollection(
            parameters: [
                new QueryParameter(key: 'order[:property]', filter: OrderFilter::class),
            ],
        )
    ],
)]

Once i do that, pagination features are not working anymore in GraphQL (if i would also apply some custom query parameter to Query or appy the filter globally, the filtering for id would not work anymore). That is different behaviour to the REST Version the above code will produce the following in the REST Version:

image

As you can see, the pagination is still there. However in GraphQL, this will happen:

image

While the return type still is a user Cursor Connection, it is not possible to pass "first, after, etc..." pagination params. The reason for it is, that inside the FieldsBuilder the $fieldConfiguration['args'] is only applied when there are no custom args/query parameters (here and here).

EDIT: That is what i would expect it to be.
image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions