You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/graphql.md
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -330,6 +330,7 @@ Note that you need to explicitly add the auto-generated queries and mutations if
330
330
As you can see, it's possible to define your own arguments for your custom queries.
331
331
They are following the GraphQL type system.
332
332
If you don't define the `args` property, it will be the default ones (for example `id` for an item).
333
+
You can also use the `extraArgs` property if you want to add more arguments than the generated ones.
333
334
334
335
If you don't want API Platform to retrieve the item for you, disable the `read` stage like in `withDefaultArgsNotRetrievedQuery`.
335
336
Some other stages [can be disabled](#disabling-resolver-stages).
@@ -344,7 +345,7 @@ Note also that:
344
345
345
346
The arguments you have defined or the default ones and their value will be in `$context['args']` of your resolvers.
346
347
347
-
You custom queries will be available like this:
348
+
Your custom queries will be available like this:
348
349
349
350
```graphql
350
351
{
@@ -467,7 +468,11 @@ use App\Resolver\BookMutationResolver;
467
468
new Mutation(name: 'update'),
468
469
new DeleteMutation(name: 'delete'),
469
470
470
-
new Mutation(name: 'mutation', resolver: BookMutationResolver::class),
471
+
new Mutation(
472
+
name: 'mutation',
473
+
resolver: BookMutationResolver::class,
474
+
extraArgs: ['id' => ['type' => 'ID!']]
475
+
),
471
476
new Mutation(
472
477
name: 'withCustomArgsMutation',
473
478
resolver: BookMutationResolver::class,
@@ -496,6 +501,7 @@ Note that you need to explicitly add the auto-generated queries and mutations if
496
501
497
502
As the custom queries, you can define your own arguments if you don't want to use the default ones (extracted from your resource).
498
503
The only difference with them is that, even if you define your own arguments, the `clientMutationId` will always be set.
504
+
You can also use the `extraArgs` property in case you need to add additional arguments (for instance to add the `id` argument since it is not added by default for a custom mutation).
499
505
500
506
The arguments will be in `$context['args']['input']` of your resolvers.
501
507
@@ -521,7 +527,7 @@ Your custom mutations will be available like this:
521
527
}
522
528
523
529
mutation {
524
-
disabledStagesMutationBook(input: {id: "/books/18", title: "The Fitz and the Fool"}) {
530
+
disabledStagesMutationBook(input: {title: "The Fitz and the Fool"}) {
0 commit comments