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: core/graphql.md
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -174,3 +174,65 @@ class Book
174
174
// ...
175
175
}
176
176
```
177
+
178
+
## Serialization Groups
179
+
180
+
You may want to restrict some resource's attributes to your GraphQL clients.
181
+
182
+
As described in the [serialization process](serialization.md) documentation, you can use serialization groups to expose only the attributes you want in queries or in mutations.
183
+
184
+
If the (de)normalization context between GraphQL and REST is different, use the `graphql` key to change it.
185
+
186
+
Note that:
187
+
188
+
* A **query** is only using the normalization context.
189
+
* A **mutation** is using the denormalization context for its input and the normalization context for its output.
190
+
191
+
The following example shows you what can be done:
192
+
193
+
```php
194
+
<?php
195
+
// api/src/Entity/Book.php
196
+
197
+
namespace App\Entity;
198
+
199
+
use ApiPlatform\Core\Annotation\ApiResource;
200
+
use Symfony\Component\Serializer\Annotation\Groups;
0 commit comments