Skip to content

Commit 62e478c

Browse files
committed
Introduce deprecationReason
1 parent 0fe6e60 commit 62e478c

33 files changed

+110
-38
lines changed

docs/todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Todo
22
This library is still work in progress, and misses some valuable features:
33

4-
- Introduction of `#[Deprecated]` attribute
4+
- ~~Introduction of `#[Deprecated]` attribute~~
55
- ~~Overwrite type via attributes~~
66
- ~~Allow simple lists (array type)~~
77
- Connection, edge, nodes (see https://relay.dev/graphql/connections.htm)

docs/usage.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Usage
2+
23
At minimum, a query and mutation needs to be defined to build a valid schema.
34

45
## Attributes
6+
57
The following attributes can be used:
68

79
- `#[Mutation]`
810
- `#[Query]`
911
- `#[InputType]`
1012
- `#[Type]`
1113
- `#[Enum]`
12-
- `#[EnumValue]`
14+
- `#[EnumValue]`
1315
- `#[Field]`
1416
- `#[Arg]`
1517

@@ -63,11 +65,12 @@ Mutations and queries:
6365

6466
Both `#[Mutation]` and `#[Query]` attribute can be configured:
6567

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 | |
7174

7275
### InputType
7376

@@ -220,9 +223,10 @@ Each case in the `enum` type can be configured as well, with the `#[EnumValue]`
220223

221224
`#[EnumValue]` attribute can be configured:
222225

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 | |
226230

227231
### Field
228232

@@ -273,11 +277,12 @@ final readonly class YourInputType
273277

274278
`#[Field]` attribute can be configured:
275279

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) | |
281286

282287
### Arg
283288

src/Attribute/EnumValue.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
{
1212
public function __construct(
1313
public ?string $description = null,
14+
public ?string $deprecationReason = null,
1415
) {}
1516
}

src/Attribute/Field.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(
1818
public ?string $name = null,
1919
public ?string $description = null,
2020
public string|Type|ScalarType|null $type = null,
21+
public ?string $deprecationReason = null,
2122
) {}
2223

2324
public function getName(): ?string

src/Attribute/Mutation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(
1818
public ?string $name = null,
1919
public ?string $description = null,
2020
public string|Type|ScalarType|null $type = null,
21+
public ?string $deprecationReason = null,
2122
) {}
2223

2324
public function getName(): ?string

src/Attribute/Query.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function __construct(
1818
public ?string $name = null,
1919
public ?string $description = null,
2020
public string|Type|ScalarType|null $type = null,
21+
public ?string $deprecationReason = null,
2122
) {}
2223

2324
public function getName(): ?string

src/Parser/Node/Child/FieldNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ public function __construct(
1919
public FieldNodeType $fieldType,
2020
public ?string $methodName,
2121
public ?string $propertyName,
22+
public ?string $deprecationReason,
2223
) {}
2324
}

src/Parser/Node/EnumValueNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
public function __construct(
1010
public string $value,
1111
public ?string $description,
12+
public ?string $deprecationReason,
1213
) {}
1314
}

src/Parser/Node/MutationNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function __construct(
1919
public array $argNodes,
2020
public Type $outputType,
2121
public string $methodName,
22+
public ?string $deprecationReason,
2223
) {}
2324

2425
public function getClassName(): string

src/Parser/Node/QueryNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function __construct(
1919
public array $argNodes,
2020
public Type $outputType,
2121
public string $methodName,
22+
public ?string $deprecationReason,
2223
) {}
2324

2425
public function getClassName(): string

0 commit comments

Comments
 (0)