|
1 | 1 | # Usage |
| 2 | + |
2 | 3 | At minimum, a query and mutation needs to be defined to build a valid schema. |
3 | 4 |
|
4 | 5 | ## Attributes |
| 6 | + |
5 | 7 | The following attributes can be used: |
6 | 8 |
|
7 | 9 | - `#[Mutation]` |
8 | 10 | - `#[Query]` |
9 | 11 | - `#[InputType]` |
10 | 12 | - `#[Type]` |
11 | 13 | - `#[Enum]` |
12 | | - - `#[EnumValue]` |
| 14 | + - `#[EnumValue]` |
13 | 15 | - `#[Field]` |
14 | 16 | - `#[Arg]` |
15 | 17 |
|
@@ -63,11 +65,12 @@ Mutations and queries: |
63 | 65 |
|
64 | 66 | Both `#[Mutation]` and `#[Query]` attribute can be configured: |
65 | 67 |
|
66 | | -| Option | Description | |
67 | | -|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
68 | | -| `name` | Set custom name of mutation or query (instead of based on class) | |
69 | | -| `description` | Set description of the mutation or query, readable in the GraphQL schema | |
70 | | -| `type` | Set custom return type; it can be:<br/>- A Type (FQCN)<br/>- A `ScalarType` (e.g. `ScalarType::Int`)<br/>- A `ListType` (e.g. `new ListType(ScalarType::Int)`)<br/>- A `NullableType` (e.g. `new NullableType(SomeType::class)`)<br/>- A combination of `ListType` and `NullableType` and a Type FQCN or `ScalarType` <br/>(e.g. `new NullableType(new ListType(ScalarType::String))`) | |
| 68 | +| Option | Description | |
| 69 | +|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 70 | +| `name` | Set custom name of mutation or query (instead of based on class) | |
| 71 | +| `description` | Set description of the mutation or query, readable in the GraphQL schema | |
| 72 | +| `type` | Set custom return type; it can be:<br/>- A Type (FQCN)<br/>- A `ScalarType` (e.g. `ScalarType::Int`)<br/>- A `ListType` (e.g. `new ListType(ScalarType::Int)`)<br/>- A `NullableType` (e.g. `new NullableType(SomeType::class)`)<br/>- A combination of `ListType` and `NullableType` and a Type FQCN or `ScalarType` <br/>(e.g. `new NullableType(new ListType(ScalarType::String))`) | |
| 73 | +| `deprecationReason` | If set, deprecates the mutation or query | | |
71 | 74 |
|
72 | 75 | ### InputType |
73 | 76 |
|
@@ -220,9 +223,10 @@ Each case in the `enum` type can be configured as well, with the `#[EnumValue]` |
220 | 223 |
|
221 | 224 | `#[EnumValue]` attribute can be configured: |
222 | 225 |
|
223 | | -| Option | Description | |
224 | | -|---------------|------------------------------------------------------------------| |
225 | | -| `description` | Set description of the enum case, readable in the GraphQL schema | |
| 226 | +| Option | Description | |
| 227 | +|---------------------|------------------------------------------------------------------| |
| 228 | +| `description` | Set description of the enum case, readable in the GraphQL schema | |
| 229 | +| `deprecationReason` | If set, deprecates the case | | |
226 | 230 |
|
227 | 231 | ### Field |
228 | 232 |
|
@@ -273,11 +277,12 @@ final readonly class YourInputType |
273 | 277 |
|
274 | 278 | `#[Field]` attribute can be configured: |
275 | 279 |
|
276 | | -| Option | Description | |
277 | | -|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
278 | | -| `name` | Set custom name of field (instead of based on class) | |
279 | | -| `description` | Set description of the field, readable in the GraphQL schema | |
280 | | -| `type` | Set custom return type; it can be:<br/>- A Type (FQCN)<br/>- A `ScalarType` (e.g. `ScalarType::Int`)<br/>- A `ListType` (e.g. `new ListType(ScalarType::Int)`)<br/>- A `NullableType` (e.g. `new NullableType(SomeType::class)`)<br/>- A combination of `ListType` and `NullableType` and a Type FQCN or `ScalarType` <br/>(e.g. `new NullableType(new ListType(ScalarType::String))`) | |
| 280 | +| Option | Description | |
| 281 | +|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 282 | +| `name` | Set custom name of field (instead of based on class) | |
| 283 | +| `description` | Set description of the field, readable in the GraphQL schema | |
| 284 | +| `type` | Set custom return type; it can be:<br/>- A Type (FQCN)<br/>- A `ScalarType` (e.g. `ScalarType::Int`)<br/>- A `ListType` (e.g. `new ListType(ScalarType::Int)`)<br/>- A `NullableType` (e.g. `new NullableType(SomeType::class)`)<br/>- A combination of `ListType` and `NullableType` and a Type FQCN or `ScalarType` <br/>(e.g. `new NullableType(new ListType(ScalarType::String))`) | |
| 285 | +| `deprecationReason` | If set, deprecates the field (`#[Type]` only) | | |
281 | 286 |
|
282 | 287 | ### Arg |
283 | 288 |
|
|
0 commit comments