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
| name | Set custom name of mutation or query (instead of based on class) |
66
+
| description | Set description of the mutation or query, readable in the GraphQL schema |
67
+
| type | Set custom return type (can be either a `#[Type]` FQCN or `ScalarType` (enum) |
68
+
| isRequired | When a custom type is set, isRequired should be set as well |
64
69
65
70
## InputType
66
-
Input types can be defined with `#[InputType]`.
71
+
72
+
Input types can be defined with `#[InputType]`.
67
73
In order to configure your class as input type, just add this attribute on class level:
68
74
69
75
```php
@@ -87,8 +93,10 @@ final readonly class YourInputType
87
93
```
88
94
89
95
### Automatic schema creation
90
-
*GraphQL Attribute Schema* will read the `__construct` signature: input arguments.
91
-
Any input argument with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten, see [Field](#field) section).
96
+
97
+
*GraphQL Attribute Schema* will read the `__construct` signature: input arguments.
98
+
Any input argument with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten,
99
+
see [Field](#field) section).
92
100
93
101
Input can be both scalars or objects.
94
102
When using objects, make sure these are defined as well with `#[InputType]` or `#[Enum]`.
@@ -106,6 +114,7 @@ options).
106
114
| description | Set description of the input type, readable in the GraphQL schema |
107
115
108
116
## Type
117
+
109
118
Types can be defined with `#[Type]`.
110
119
In order to configure your class as type, just add this attribute on class level:
111
120
@@ -136,12 +145,16 @@ final readonly class YourType
136
145
```
137
146
138
147
### Automatic schema creation
148
+
139
149
*GraphQL Attribute Schema* will both read the `__construct` signature: input arguments, as well as read all methods.
140
150
141
-
Any input argument with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten, see [Field](#field) section).
151
+
Any input argument with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten,
152
+
see [Field](#field) section).
142
153
143
-
Any method with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten, see [Field](#field) section).
144
-
The return type is seen as field type, any method input arguments are seen as filter arguments (this can be overwritten by using `#[Arg]`, see [Arg](#arg) section)..
154
+
Any method with a defined `#[Field]` will be automatically configured in the schema (this can be overwritten,
155
+
see [Field](#field) section).
156
+
The return type is seen as field type, any method input arguments are seen as filter arguments (this can be overwritten
157
+
by using `#[Arg]`, see [Arg](#arg) section)..
145
158
146
159
Input can be both scalars or objects.
147
160
When using objects, make sure these are defined as well with `#[InputType]` or `#[Enum]`.
@@ -159,6 +172,7 @@ options).
159
172
| description | Set description of the type, readable in the GraphQL schema |
160
173
161
174
## Enum
175
+
162
176
Enums can be defined with `#[Enum]`.
163
177
In order to configure your enum class as enum, just add this attribute on class level:
164
178
@@ -173,14 +187,17 @@ enum YourEnumType: string
173
187
case Baz = 'BAZ';
174
188
}
175
189
```
190
+
176
191
### Automatic schema creation
192
+
177
193
*GraphQL Attribute Schema* will read the enum signature.
178
194
179
195
The values for the enum will be automatically read from the PHP `enum`; it uses the string version.
180
196
181
197
The name of the enum will be automatically read from the class name (this can be overwritten, see options).
182
198
183
199
### Requirements
200
+
184
201
Enums:
185
202
186
203
- must be of the PHP native `enum` type (no classes with public constants)
@@ -196,6 +213,7 @@ Enums:
196
213
| description | Set description of the enum, readable in the GraphQL schema |
197
214
198
215
## Field
216
+
199
217
In `#[Type]` and `#[InputType]`, to define fields, the `#[Field]` attribute can be used.
200
218
In order to configure any fields this can be set on constructor property (for `#[InputType]` or `#[Type]`) or
201
219
on method (for `#[Type]` only).
@@ -243,14 +261,17 @@ final readonly class YourInputType
0 commit comments