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
+44-54
Original file line number
Diff line number
Diff line change
@@ -41,48 +41,50 @@ class Coordinates {
41
41
42
42
## Index
43
43
44
-
@Access
44
+
[@Access](#access)
45
45
46
-
@Arg
46
+
[@Arg](#arg)
47
47
48
-
@Deprecated
48
+
[@Deprecated](#deprecated)
49
49
50
-
@Description
50
+
[@Description](#description)
51
51
52
-
@Enum
52
+
[@Enum](#enum)
53
53
54
-
@EnumValue
54
+
[@EnumValue](#enumvalue)
55
55
56
-
@Field
56
+
[@Field](#field)
57
57
58
-
@FieldsBuilder
58
+
[@FieldsBuilder](#fieldsbuilder)
59
59
60
-
@Input
60
+
[@Input](#input)
61
61
62
-
@IsPublic
62
+
[@IsPublic](#ispublic)
63
63
64
-
@Mutation
64
+
[@Mutation](#mutation)
65
65
66
-
@Provider
66
+
[@Provider](#provider)
67
67
68
-
@Query
68
+
[@Query](#query)
69
69
70
-
@Type
70
+
[@Type](#type)
71
71
72
-
@TypeInterface
72
+
[@TypeInterface](#typeinterface)
73
73
74
-
@Scalar
74
+
[@Scalar](#scalar)
75
75
76
-
@Union
76
+
[@Union](#union)
77
77
78
-
@Relay\Connection
78
+
[@Relay\Connection](#relayconnection)
79
79
80
-
@Relay\Edge
80
+
[@Relay\Edge](#relayedge)
81
+
82
+
---
81
83
82
84
## @Access
83
85
84
-
Added on a _class_ in conjonction with `@Type` or `@TypeInterface`, this annotation will define the default access type on this fields.
85
-
Added on a _property_ or _method_ in conjonction with `@Field`, it'll define the access type on this particular field.
86
+
Added on a _class_ in conjunction with `@Type` or `@TypeInterface`, this annotation will define the default access type on this fields.
87
+
Added on a _property_ or _method_ in conjunction with `@Field`, it'll define the access type on this particular field.
86
88
87
89
Example:
88
90
@@ -105,7 +107,6 @@ class Hero {
105
107
*/
106
108
public $secret;
107
109
}
108
-
?>
109
110
```
110
111
111
112
## @Arg
@@ -146,12 +147,11 @@ class Hero {
146
147
*/
147
148
public $friends;
148
149
}
149
-
?>
150
150
```
151
151
152
152
## @Deprecated
153
153
154
-
This annotation is used in conjonction with `@Field` to mark it as deprecated with the specified reason.
154
+
This annotation is used in conjunction with `@Field` to mark it as deprecated with the specified reason.
155
155
156
156
Example
157
157
@@ -173,12 +173,11 @@ class Hero {
173
173
*/
174
174
public $age;
175
175
}
176
-
?>
177
176
```
178
177
179
178
## @Description
180
179
181
-
This annotation is used in conjonction with one of `@Enum`, `@Field`, `@Input`, `@Scalar`, `@Type`, `@TypeInterface`, `@Union` to set a description for the GraphQL object.
180
+
This annotation is used in conjunction with one of `@Enum`, `@Field`, `@Input`, `@Scalar`, `@Type`, `@TypeInterface`, `@Union` to set a description for the GraphQL object.
182
181
183
182
Example
184
183
@@ -196,12 +195,11 @@ class Hero {
196
195
*/
197
196
public $name;
198
197
}
199
-
?>
200
198
```
201
199
202
200
## @Enum
203
201
204
-
This annotation applies on _class_ to define it as a enum. The constants defined on the class will be the enum values.
202
+
This annotation applies on _class_ to define it as a `enum`. The constants defined on the class will be the enum values.
205
203
In order to add more meta on the values (like description or deprecated reason), you have to provided them as `@EnumValue` in the `values` attribute with a `name` attribute referencing a constant name. You just need to do it for the constants you want to add meta on.
206
204
207
205
Optional attributes:
@@ -232,10 +230,9 @@ class Planet
232
230
233
231
public $value;
234
232
}
235
-
?>
236
233
```
237
234
238
-
In the example above, if a query or mutation has this Enum as an argument, the value will be an instanceof the class with the enum value as the `value` property. (see [The Arguments Transformer documentation](arguments-transformer.md)).
235
+
In the example above, if a query or mutation has this Enum as an argument, the value will be an instance of the class with the enum value as the `value` property. (see [The Arguments Transformer documentation](arguments-transformer.md)).
239
236
As the class can be instanciated from the `Arguments Transformer` service, it cannot have a constructor with required arguments.
240
237
241
238
## @EnumValue
@@ -257,17 +254,17 @@ This annotation can be defined on a _property_ or a _method_.
257
254
258
255
If it is defined on a _method_:
259
256
260
-
- If no `resolve` attribute is define, it will default to `@=value.methodName(...args)"`, so the method itself will be used as the field resolver. You can then specify a `name` for this field (or it's the method name that will be use).
257
+
- If no `resolve` attribute is defined, it will default to `@=value.methodName(...args)"`, so the method itself will be used as the field resolver. You can then specify a `name` for this field (or the method's name will be use).
261
258
262
259
If it is defined on a _method_ of the Root Query or the Root mutation :
263
260
264
-
- If not `resolve` attribute is define, it will default to `@=service(FQN).methodName(...args)"` with `FQN` being the fully qualified name of the Root Query class or Root Mutation.
261
+
- If not `resolve` attribute is defined, it will default to `@=service(FQN).methodName(...args)"` with `FQN` being the fully qualified name of the Root Query class or Root Mutation.
265
262
266
263
Optional attributes:
267
264
268
-
-**type** : The GraphqL type of the field. This attribute can sometimes be auto guess from Doctrine ORM annotations
265
+
-**type** : The GraphqL type of the field. This attribute can sometimes be guessed automatically from Doctrine ORM annotations
269
266
-**name** : The GraphQL name of the field (default to the property name). If you don't specify a `resolve` attribute while changing the `name`, the default one will be '@=value.<property_name>'
270
-
-**args** : A array of `@Arg`
267
+
-**args** : An array of `@Arg`
271
268
-**resolve** : A resolution expression
272
269
-**fieldBuilder** : A field builder to use. Either as string (will be the field builder name), or as an array, first index will the name of the builder and second one will be the config.
273
270
-**argsBuilder** : An args builder to use. Either as string (will be the args builder name), or as an array, first index will the name of the builder and second one will be the config.
@@ -295,7 +292,6 @@ class Hero {
295
292
*/
296
293
public $friends;
297
294
}
298
-
?>
299
295
```
300
296
301
297
Example on methods:
@@ -318,7 +314,6 @@ class Hero {
318
314
return array_slice($this->friends, 0, $limit);
319
315
}
320
316
}
321
-
?>
322
317
```
323
318
324
319
## @FieldsBuilder
@@ -345,13 +340,12 @@ Example:
345
340
class MyType {
346
341
347
342
}
348
-
?>
349
343
```
350
344
351
345
## @Input
352
346
353
347
This annotation is used on a _class_ to define an input type.
354
-
An Input type is pretty much the same as an input except:
348
+
An Input type is pretty much the same as an input, except:
355
349
356
350
- Dynamic `@Field` with `resolve` attribute are ignored.
357
351
@@ -360,12 +354,12 @@ Optional attributes:
360
354
-**name** : The GraphQL name of the input field (default to classnameInput )
361
355
-**isRelay** : Set to true if you want your input to be relay compatible (ie. An extra field `clientMutationId` will be added to the input)
362
356
363
-
The corresponding class will also be used by the `Arguments Transformer` service. A instance of the corresponding class will be use as the `input` value if it is an argument of a query or mutation. (see [The Arguments Transformer documentation](arguments-transformer.md)).
357
+
The corresponding class will also be used by the `Arguments Transformer` service. An instance of the corresponding class will be use as the `input` value if it is an argument of a query or mutation. (see [The Arguments Transformer documentation](arguments-transformer.md)).
364
358
365
359
## @IsPublic
366
360
367
-
Added on a _class_ in conjonction with `@Type` or `@TypeInterface`, this annotation will define the defaut to set if fields are public or not.
368
-
Added on a _property_ or _method_ in conjonction with `@Field`, it'll define an expression to set if the field is public or not.
361
+
Added on a _class_ in conjunction with `@Type` or `@TypeInterface`, this annotation will define the defaut to set if fields are public or not.
362
+
Added on a _property_ or _method_ in conjunction with `@Field`, it'll define an expression to set if the field is public or not.
369
363
370
364
Example:
371
365
@@ -383,18 +377,17 @@ class SecretArea {
383
377
*/
384
378
public $secretCode;
385
379
}
386
-
?>
387
380
```
388
381
389
382
## @Mutation
390
383
391
-
This annotation applies on methods for classes tagged with the `@Provider` annotation. It indicates that on this class a method will resolve a Mutation field.
392
-
The resulting field is added to the root Mutation type (define in configuration at key `overblog_graphql.definitions.schema.mutation`).
393
-
The class exposing the mutation(s) must have a corresponding service with his className.
384
+
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.
385
+
The resulting field is added to the root Mutation type (defined in configuration at key `overblog_graphql.definitions.schema.mutation`).
386
+
The class exposing the mutation(s) must be declared as a [service](https://symfony.com/doc/current/service_container.html).
394
387
395
388
Example:
396
389
397
-
This will add a`updateUserEmail` mutation, with as resolver `@=service('App\Graphql\MutationProvider').updateUserEmail(...)`.
390
+
This will add an`updateUserEmail` mutation, with as resolver `@=service('App\Graphql\MutationProvider').updateUserEmail(...)`.
398
391
399
392
```php
400
393
<?php
@@ -420,14 +413,13 @@ class MutationProvider {
420
413
return $user;
421
414
}
422
415
}
423
-
?>
424
416
```
425
417
426
418
## @Provider
427
419
428
-
This annotation applies on classes to indicate that it containts methods tagged with `@Query`o or `@Mutation`.
420
+
This annotation applies on classes to indicate that it contains methods tagged with `@Query` or `@Mutation`.
429
421
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**.
430
-
You can use `@Access` and/or `@IsPublic` on a provider class to add default access or visibility on query or mutation defined.
422
+
You can use `@Access` and/or `@IsPublic` on a provider class to add default access or visibility on defined query or mutation.
431
423
432
424
Optional attributes:
433
425
@@ -437,7 +429,7 @@ Optional attributes:
437
429
438
430
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.
439
431
By default, the resulting field is added to the root Query type (define in configuration at key `overblog_graphql.definitions.schema.query`).
440
-
The class exposing the querie(s) must have a corresponding service with his className.
432
+
The class exposing the query(ies) must be declared as a [service](https://symfony.com/doc/current/service_container.html).
441
433
442
434
Optional attributes:
443
435
@@ -464,7 +456,6 @@ class UsersProviders {
464
456
return $this->repository->findAll();
465
457
}
466
458
}
467
-
?>
468
459
```
469
460
470
461
## @Type
@@ -474,7 +465,7 @@ This annotation is used on _class_ to define a GraphQL Type.
474
465
Optional attributes:
475
466
476
467
-**name** : The GraphQL name of the type (default to the class name without namespace)
477
-
-**interfaces** : An array of GraphQL interface this type herits from
468
+
-**interfaces** : An array of GraphQL interface this type inherits from
478
469
-**isRelay** : Set to true to have a Relay compatible type (ie. A `clientMutationId` will be added).
479
470
-**builders**: An array of `@FieldsBuilder` annotations
0 commit comments