Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
toitzi opened this issue Oct 7, 2024 · 1 comment
Closed

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

toitzi opened this issue Oct 7, 2024 · 1 comment
Assignees
Labels

Comments

@toitzi
Copy link
Contributor

toitzi commented Oct 7, 2024

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

@soyuka
Copy link
Member

soyuka commented Oct 7, 2024

Really interesting, I'll add a test for this thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants