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
+6-7
Original file line number
Diff line number
Diff line change
@@ -386,7 +386,7 @@ The class exposing the mutation(s) must be declared as a [service](https://symfo
386
386
387
387
Optional attributes:
388
388
389
-
-**targetType** : The GraphQL type 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)).
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.
390
390
391
391
Example:
392
392
@@ -422,7 +422,7 @@ class MutationProvider {
422
422
423
423
This annotation applies on classes to indicate that it contains methods tagged with `@Query` or `@Mutation`.
424
424
Without it, the `@Query` and `@Mutation` are ignored. When used, **remember to have a corresponding service with the fully qualified name of the class as service id**.
425
-
You can use `@Access` and/or `@IsPublic` on a provider class to add default access or visibility on defined query or mutation.
425
+
You can use `@Access` and/or `@IsPublic` on a provider class to add default access or visibility on defined query or mutation.
426
426
427
427
Optional attributes:
428
428
@@ -436,7 +436,7 @@ The class exposing the query(ies) must be declared as a [service](https://symfon
436
436
437
437
Optional attributes:
438
438
439
-
-**targetType** : The GraphQL type 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)).
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.
440
440
441
441
Example:
442
442
@@ -589,19 +589,18 @@ class Pet {
589
589
}
590
590
```
591
591
592
-
593
592
## @Relay\Connection
594
593
595
-
This annotation extends the `@Type` annotation so it uses the same attributes.
594
+
This annotation extends the `@Type` annotation so it uses the same attributes.
596
595
It prepends the `RelayConnectionFieldsBuilder` to the list of fields builders.
597
596
598
597
The extra attributes are :
599
598
600
599
-**edge** : The GraphQL type of the connection's edges
601
-
-**node** : The GraphQL type of the node of the connection's edges'
600
+
-**node** : The GraphQL type of the node of the connection's edges'
602
601
603
602
You must define one and only one of this attributes.
604
-
If the `edge` attribute is used, the declaration is the same as adding a `RelayConnectionFieldsBuilder`
603
+
If the `edge` attribute is used, the declaration is the same as adding a `RelayConnectionFieldsBuilder`
Copy file name to clipboardExpand all lines: src/Config/Parser/AnnotationParser.php
+15-6
Original file line number
Diff line number
Diff line change
@@ -674,19 +674,28 @@ private static function getGraphQLFieldsFromProviders(GraphClass $graphClass, st
674
674
continue;
675
675
}
676
676
677
-
$annotationTarget = $annotation->targetType;
678
-
if (!$annotationTarget && $isDefaultTarget) {
679
-
$annotationTarget = $targetType;
680
-
if (!($annotationinstanceof$expectedAnnotation)) {
677
+
$annotationTargets = $annotation->targetType;
678
+
679
+
if (null === $annotationTargets) {
680
+
if ($isDefaultTarget) {
681
+
$annotationTargets = [$targetType];
682
+
if (!$annotationinstanceof$expectedAnnotation) {
683
+
continue;
684
+
}
685
+
} else {
681
686
continue;
682
687
}
683
688
}
684
689
685
-
if ($annotationTarget !== $targetType) {
690
+
if (is_string($annotationTargets)) {
691
+
$annotationTargets = [$annotationTargets];
692
+
}
693
+
694
+
if (!in_array($targetType, $annotationTargets)) {
686
695
continue;
687
696
}
688
697
689
-
if (!($annotationinstanceof$expectedAnnotation)) {
698
+
if (!$annotationinstanceof$expectedAnnotation) {
690
699
if (GQL\Mutation::class == $expectedAnnotation) {
691
700
$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);
0 commit comments