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
Refactor GraphQL & extending documentations for clarity and accuracy
Updated terminology from "stages" to "providers and processors" for better clarity. Removed redundant sections to streamline information on custom mutations and configuration examples.
@@ -409,13 +409,12 @@ final class BookCollectionResolver implements QueryCollectionResolverInterface
409
409
}
410
410
```
411
411
412
-
### Custom Queries config for Symfony
412
+
### Custom Queries config for Symfony
413
413
414
414
If you use autoconfiguration (the default Symfony configuration) in your application, then you are done!
415
415
416
416
Else, you need to tag your resolver like this if you using Symfony without autoconfiguration :
417
417
418
-
419
418
```yaml
420
419
# api/config/services.yaml
421
420
services:
@@ -633,8 +632,8 @@ They are following the GraphQL type system.
633
632
If you don't define the `args` property, it will be the default ones (for example `id` for an item).
634
633
You can also use the `extraArgs` property if you want to add more arguments than the generated ones.
635
634
636
-
If you don't want API Platform to retrieve the item for you, disable the `read` stage like in `withDefaultArgsNotRetrievedQuery`.
637
-
Some other stages [can be disabled](#disabling-resolver-stages).
635
+
If you don't want API Platform to retrieve the item for you, disable the `read` provider.
636
+
Some other providers and processors [can be disabled](#disabling-system-providers-and-processors).
638
637
Another option would be to make sure there is no `id` argument.
639
638
This is the case for `notRetrievedQuery` (empty args).
640
639
Conversely, if you need to add custom arguments, make sure `id` is added among the arguments if you need the item to be retrieved automatically.
@@ -737,145 +736,17 @@ final class BookMutationResolver implements MutationResolverInterface
737
736
```
738
737
739
738
As you can see, depending on how you configure your custom mutation in the resource, the item is retrieved or not.
740
-
For instance, if you don't set an `id` argument or if you disable the `read` or the `deserialize` stage (other stages [can also be disabled](#disabling-resolver-stages)),
739
+
For instance, if you don't set an `id` argument or if you disable the `read` or the `deserialize` providers (other state providers and state processors [can also be disabled](#disabling-system-providers-and-processors)),
741
740
the received item will be `null`.
742
741
743
742
Likewise, if you don't want your item to be persisted by API Platform,
744
-
you can return `null` instead of the mutated item (be careful: the response will also be `null`) or disable the `write` stage.
743
+
you can return `null` instead of the mutated item (be careful: the response will also be `null`) or disable the `write` provider.
745
744
746
745
Don't forget the resolver is a service and you can inject the dependencies you want.
747
746
748
747
If you don't use autoconfiguration, add the tag `api_platform.graphql.mutation_resolver` to the resolver service.
749
748
If you're using Laravel, don't forget to tag the resolver service with the `ApiPlatform\GraphQl\Resolver\MutationResolverInterface`.
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).
880
751
881
752
As the custom queries, you can define your own arguments if you don't want to use the default ones (extracted from your resource).
@@ -884,38 +755,6 @@ You can also use the `extraArgs` property in case you need to add additional arg
884
755
885
756
The arguments will be in `$context['args']['input']` of your resolvers.
886
757
887
-
Your custom mutations will be available like this:
888
-
889
-
```graphql
890
-
{
891
-
mutation {
892
-
mutationBook(input: {id: "/books/18", title: "The Fitz and the Fool"}) {
disabledStagesMutationBook(input: {title: "The Fitz and the Fool"}) {
910
-
book {
911
-
title
912
-
}
913
-
clientMutationId
914
-
}
915
-
}
916
-
}
917
-
```
918
-
919
758
## Subscriptions
920
759
921
760
Subscriptions are an [RFC](https://github.com/graphql/graphql-spec/blob/master/rfcs/Subscriptions.md#rfc-graphql-subscriptions) to allow a client to receive pushed realtime data from the server.
@@ -1043,9 +882,9 @@ See the [Extending API Platform](extending.md) documentation for more informatio
1043
882
1044
883
### Disabling system providers and processors
1045
884
1046
-
If you need to, you can disable some stages done by the resolvers, for instance if you don't want your data to be validated.
885
+
If you need to, you can disable some states providers and state processors done by the resolvers, for instance if you don't want your data to be validated.
1047
886
1048
-
The following table lists the stages you can disable in your resource configuration.
887
+
The following table lists the system states providers and states processors you can disable in your resource configuration.
@@ -2760,8 +2599,7 @@ You can also check the documentation of [graphql-php](https://webonyx.github.io/
2760
2599
The big difference in API Platform is that the value is already serialized when it's received in your type class.
2761
2600
Similarly, you would not want to denormalize your parsed value since it will be done by API Platform later.
2762
2601
2763
-
2764
-
#### Custom Types config for Symfony
2602
+
### Custom Types config for Symfony
2765
2603
2766
2604
If you use autoconfiguration (the default Symfony configuration) in your application, then you are done!
2767
2605
@@ -2781,7 +2619,7 @@ Your custom type is now registered and is available in the `TypesContainer`.
2781
2619
To use it please [modify the extracted types](#modify-the-extracted-types) or use it directly in [custom queries](#custom-queries) or [custom mutations](#custom-mutations).
2782
2620
2783
2621
2784
-
#### Custom Types config for Laravel
2622
+
### Custom Types config for Laravel
2785
2623
2786
2624
If you are using Laravel tag your type with:
2787
2625
@@ -2928,7 +2766,7 @@ final class BookContextBuilder implements SerializerContextBuilderInterface
2928
2766
}
2929
2767
```
2930
2768
2931
-
## Export the Schema in SDL
2769
+
## Export the Schema in SDL
2932
2770
2933
2771
> [!WARNING]
2934
2772
> These commands are only available for API Platform with Symfony!
0 commit comments