Skip to content

Commit 5acda18

Browse files
authored
Merge pull request #530 from overblog/murtukov-patch-1
Update annotations-reference.md
2 parents 0b6d8a2 + 88cfdd6 commit 5acda18

File tree

1 file changed

+44
-54
lines changed

1 file changed

+44
-54
lines changed

docs/annotations/annotations-reference.md

+44-54
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,50 @@ class Coordinates {
4141

4242
## Index
4343

44-
@Access
44+
[@Access](#access)
4545

46-
@Arg
46+
[@Arg](#arg)
4747

48-
@Deprecated
48+
[@Deprecated](#deprecated)
4949

50-
@Description
50+
[@Description](#description)
5151

52-
@Enum
52+
[@Enum](#enum)
5353

54-
@EnumValue
54+
[@EnumValue](#enumvalue)
5555

56-
@Field
56+
[@Field](#field)
5757

58-
@FieldsBuilder
58+
[@FieldsBuilder](#fieldsbuilder)
5959

60-
@Input
60+
[@Input](#input)
6161

62-
@IsPublic
62+
[@IsPublic](#ispublic)
6363

64-
@Mutation
64+
[@Mutation](#mutation)
6565

66-
@Provider
66+
[@Provider](#provider)
6767

68-
@Query
68+
[@Query](#query)
6969

70-
@Type
70+
[@Type](#type)
7171

72-
@TypeInterface
72+
[@TypeInterface](#typeinterface)
7373

74-
@Scalar
74+
[@Scalar](#scalar)
7575

76-
@Union
76+
[@Union](#union)
7777

78-
@Relay\Connection
78+
[@Relay\Connection](#relayconnection)
7979

80-
@Relay\Edge
80+
[@Relay\Edge](#relayedge)
81+
82+
---
8183

8284
## @Access
8385

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.
8688

8789
Example:
8890

@@ -105,7 +107,6 @@ class Hero {
105107
*/
106108
public $secret;
107109
}
108-
?>
109110
```
110111

111112
## @Arg
@@ -146,12 +147,11 @@ class Hero {
146147
*/
147148
public $friends;
148149
}
149-
?>
150150
```
151151

152152
## @Deprecated
153153

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.
155155

156156
Example
157157

@@ -173,12 +173,11 @@ class Hero {
173173
*/
174174
public $age;
175175
}
176-
?>
177176
```
178177

179178
## @Description
180179

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.
182181

183182
Example
184183

@@ -196,12 +195,11 @@ class Hero {
196195
*/
197196
public $name;
198197
}
199-
?>
200198
```
201199

202200
## @Enum
203201

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.
205203
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.
206204

207205
Optional attributes:
@@ -232,10 +230,9 @@ class Planet
232230

233231
public $value;
234232
}
235-
?>
236233
```
237234

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)).
239236
As the class can be instanciated from the `Arguments Transformer` service, it cannot have a constructor with required arguments.
240237

241238
## @EnumValue
@@ -257,17 +254,17 @@ This annotation can be defined on a _property_ or a _method_.
257254

258255
If it is defined on a _method_:
259256

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).
261258

262259
If it is defined on a _method_ of the Root Query or the Root mutation :
263260

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.
265262

266263
Optional attributes:
267264

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
269266
- **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`
271268
- **resolve** : A resolution expression
272269
- **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.
273270
- **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 {
295292
*/
296293
public $friends;
297294
}
298-
?>
299295
```
300296

301297
Example on methods:
@@ -318,7 +314,6 @@ class Hero {
318314
return array_slice($this->friends, 0, $limit);
319315
}
320316
}
321-
?>
322317
```
323318

324319
## @FieldsBuilder
@@ -345,13 +340,12 @@ Example:
345340
class MyType {
346341

347342
}
348-
?>
349343
```
350344

351345
## @Input
352346

353347
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:
355349

356350
- Dynamic `@Field` with `resolve` attribute are ignored.
357351

@@ -360,12 +354,12 @@ Optional attributes:
360354
- **name** : The GraphQL name of the input field (default to classnameInput )
361355
- **isRelay** : Set to true if you want your input to be relay compatible (ie. An extra field `clientMutationId` will be added to the input)
362356

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)).
364358

365359
## @IsPublic
366360

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.
369363

370364
Example:
371365

@@ -383,18 +377,17 @@ class SecretArea {
383377
*/
384378
public $secretCode;
385379
}
386-
?>
387380
```
388381

389382
## @Mutation
390383

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).
394387

395388
Example:
396389

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(...)`.
398391

399392
```php
400393
<?php
@@ -420,14 +413,13 @@ class MutationProvider {
420413
return $user;
421414
}
422415
}
423-
?>
424416
```
425417

426418
## @Provider
427419

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`.
429421
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.
431423

432424
Optional attributes:
433425

@@ -437,7 +429,7 @@ Optional attributes:
437429

438430
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.
439431
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).
441433

442434
Optional attributes:
443435

@@ -464,7 +456,6 @@ class UsersProviders {
464456
return $this->repository->findAll();
465457
}
466458
}
467-
?>
468459
```
469460

470461
## @Type
@@ -474,7 +465,7 @@ This annotation is used on _class_ to define a GraphQL Type.
474465
Optional attributes:
475466

476467
- **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
478469
- **isRelay** : Set to true to have a Relay compatible type (ie. A `clientMutationId` will be added).
479470
- **builders**: An array of `@FieldsBuilder` annotations
480471

@@ -490,7 +481,6 @@ class Hero {
490481
*/
491482
public $name;
492483
}
493-
?>
494484
```
495485

496486
## @TypeInterface
@@ -680,4 +670,4 @@ class MyEdge {}
680670
* })
681671
*/
682672
class MyEdge {}
683-
```
673+
```

0 commit comments

Comments
 (0)