Skip to content

Commit 9b049f4

Browse files
authored
Update graphql.md (#1347)
1 parent a87a2d3 commit 9b049f4

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

core/graphql.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -288,28 +288,35 @@ use App\Resolver\BookResolver;
288288
289289
#[ApiResource(
290290
graphql: [
291-
'retrievedQuery' => [
292-
'item_query' => BookResolver::class
293-
],
294-
'notRetrievedQuery' => [
295-
'item_query' => BookResolver::class,
296-
'args' => []
297-
],
298-
'withDefaultArgsNotRetrievedQuery' => [
299-
'item_query' => BookResolver::class,
300-
'read' => false
301-
],
302-
'withCustomArgsQuery' => [
303-
'item_query' => BookResolver::class,
304-
'args' => [
305-
'id' => ['type' => 'ID!'],
306-
'log' => ['type' => 'Boolean!', 'description' => 'Is logging activated?'],
307-
'logDate' => ['type' => 'DateTime']
308-
]
309-
],
310-
'collectionQuery' => [
311-
'collection_query' => BookCollectionResolver::class
312-
]
291+
// Auto-generated queries and mutations
292+
'item_query',
293+
'collection_query',
294+
'create',
295+
'update',
296+
'delete',
297+
298+
'retrievedQuery' => [
299+
'item_query' => BookResolver::class
300+
],
301+
'notRetrievedQuery' => [
302+
'item_query' => BookResolver::class,
303+
'args' => []
304+
],
305+
'withDefaultArgsNotRetrievedQuery' => [
306+
'item_query' => BookResolver::class,
307+
'read' => false
308+
],
309+
'withCustomArgsQuery' => [
310+
'item_query' => BookResolver::class,
311+
'args' => [
312+
'id' => ['type' => 'ID!'],
313+
'log' => ['type' => 'Boolean!', 'description' => 'Is logging activated?'],
314+
'logDate' => ['type' => 'DateTime']
315+
]
316+
],
317+
'collectionQuery' => [
318+
'collection_query' => BookCollectionResolver::class
319+
]
313320
]
314321
)]
315322
class Book
@@ -318,6 +325,8 @@ class Book
318325
}
319326
```
320327

328+
Note that you need to explicitly add the auto-generated queries and mutations if they are needed when configuring custom queries, like it's done for the [operations](#operations).
329+
321330
As you can see, it's possible to define your own arguments for your custom queries.
322331
They are following the GraphQL type system.
323332
If you don't define the `args` property, it will be the default ones (for example `id` for an item).
@@ -445,6 +454,13 @@ use App\Resolver\BookMutationResolver;
445454
446455
#[ApiResource(
447456
graphql: [
457+
// Auto-generated queries and mutations
458+
'item_query',
459+
'collection_query',
460+
'create',
461+
'update',
462+
'delete',
463+
448464
'mutation' => [
449465
'mutation' => BookMutationResolver::class
450466
],
@@ -467,6 +483,8 @@ class Book
467483
}
468484
```
469485

486+
Note that you need to explicitly add the auto-generated queries and mutations if they are needed when configuring custom mutations, like it's done for the [operations](#operations).
487+
470488
As the custom queries, you can define your own arguments if you don't want to use the default ones (extracted from your resource).
471489
The only difference with them is that, even if you define your own arguments, the `clientMutationId` will always be set.
472490

0 commit comments

Comments
 (0)