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: docs/annotations/annotations-reference.md
+19-5Lines changed: 19 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -381,12 +381,18 @@ class SecretArea {
381
381
## @Mutation
382
382
383
383
This annotation applies on methods for classes tagged with the `@Provider` annotation. It indicates that the method on this class will resolve a Mutation field.
384
-
The resulting field is added to the root Mutation type (defined in configuration at key `overblog_graphql.definitions.schema.mutation`).
384
+
The corresponding GraphQL field is added to the GraphQL type(s) following the logic:
385
+
- The type(s) specified in the `targetTypes` attribute of the `@Mutation` annotation if it's defined.
386
+
or
387
+
- The type(s) specified in the `targetMutationTypes` attribute of the `@Provider` annotation if it's defined.
388
+
or
389
+
- The root Query type of the default schema (defined in configuration at key `overblog_graphql.definitions.schema.mutation` or `overblog_graphql.definitions.schema.default.mutation`).
390
+
385
391
The class exposing the mutation(s) must be declared as a [service](https://symfony.com/doc/current/service_container.html).
386
392
387
393
Optional attributes:
388
394
389
-
-**targetType** : The GraphQL type(s) to attach the field to. It must be a mutation. (by default, it'll be the root Mutation type of the default schema. see [Default Schema](../definitions/schema.md#default-schema)). You can specify one or multiple target types.
395
+
-**targetTypes** : The GraphQL type(s) to attach the field to. It must be a mutation. (by default, it'll be the root Mutation type of the default schema. see [Default Schema](../definitions/schema.md#default-schema)). You can specify one or multiple target types.
390
396
391
397
Example:
392
398
@@ -426,17 +432,25 @@ You can use `@Access` and/or `@IsPublic` on a provider class to add default acce
426
432
427
433
Optional attributes:
428
434
429
-
-**prefix** : A prefix to apply to all field names from this provider
435
+
-**prefix**: A prefix to apply to all field names from this provider
436
+
-**targetQueryTypes**: The default GraphQL type(s) to attach the provider `@Query` to
437
+
-**targetMutationTypes**: The default GraphQL type(s) to attach the provider `@Mutation` to
430
438
431
439
## @Query
432
440
433
441
This annotation applies on methods for classes tagged with the `@Provider` annotation. It indicates that on this class a method will resolve a Query field.
434
-
By default, the resulting field is added to the root Query type (define in configuration at key `overblog_graphql.definitions.schema.query`).
442
+
The corresponding GraphQL field is added to the GraphQL type(s) following the logic:
443
+
- The type(s) specified in the `targetTypes` attribute of the `@Query` annotation if it's defined.
444
+
or
445
+
- The type(s) specified in the `targetQueryTypes` attribute of the `@Provider` annotation if it's defined.
446
+
or
447
+
- The root Query type of the default schema (defined in configuration at key `overblog_graphql.definitions.schema.query` or `overblog_graphql.definitions.schema.default.query`).
448
+
435
449
The class exposing the query(ies) must be declared as a [service](https://symfony.com/doc/current/service_container.html).
436
450
437
451
Optional attributes:
438
452
439
-
-**targetType** : The GraphQL type(s) to attach the field to (by default, it'll be the root Query type of the default schema. see [Default Schema](../definitions/schema.md#default-schema)). You can specify one or multiple target types.
453
+
-**targetTypes** : The GraphQL type(s) to attach the field to (by default, it'll be the root Query type of the default schema. see [Default Schema](../definitions/schema.md#default-schema)). You can specify one or multiple target types.
@@ -728,7 +737,7 @@ private static function getGraphQLFieldsFromProviders(GraphClass $graphClass, st
728
737
}
729
738
730
739
if (!$annotationinstanceof$expectedAnnotation) {
731
-
if (GQL\Mutation::class == $expectedAnnotation) {
740
+
if (GQL\Mutation::class ===$expectedAnnotation) {
732
741
$message = sprintf('The provider "%s" try to add a query field on type "%s" (through @Query on method "%s") but "%s" is a mutation.', $providerMetadata->getName(), $targetType, $method->getName(), $targetType);
733
742
} else {
734
743
$message = sprintf('The provider "%s" try to add a mutation on type "%s" (through @Mutation on method "%s") but "%s" is not a mutation.', $providerMetadata->getName(), $targetType, $method->getName(), $targetType);
0 commit comments