Skip to content

Commit 557459a

Browse files
Docs for GQL query and mutation aliases
See parse-community/parse-server#6257 parse-community/parse-server#6258
1 parent 5a685ad commit 557459a

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

_includes/graphql/customisation.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,21 @@ interface ParseGraphQLConfiguration {
6565
query?: {
6666
get?: boolean;
6767
find?: boolean;
68+
getAlias?: String;
69+
findAlias?: String;
6870
};
6971

7072
// By default, all write mutation types are
7173
// exposed for all included classes. Use this to disable
72-
// the available mutation types for this class.
74+
// the available mutation types for this class and optionally
75+
// override the default generated name with aliases.
7376
mutation?: {
7477
create?: boolean;
7578
update?: boolean;
7679
destroy?: boolean;
80+
createAlias?: String,
81+
updateAlias?: String,
82+
destroyAlias?: String,
7783
};
7884
}>
7985
}
@@ -214,6 +220,27 @@ By default, the schema exposes a `get` and `find` operation for each class, for
214220
}
215221
```
216222

223+
By default, generated query names use pluralized version of `className`. You can override this behaviour with `getAlias`/`findAlias`. This is useful when your collection is named in plural or when singular/plural forms are same e.g. `Data`:
224+
225+
```javascript
226+
{
227+
"classConfigs": [
228+
{
229+
"className": "Likes",
230+
"query": {
231+
"getAlias": "like"
232+
}
233+
},
234+
{
235+
"className": "Data",
236+
"query": {
237+
"findAlias": "findData"
238+
}
239+
}
240+
]
241+
}
242+
243+
```
217244
### Mutations
218245

219246
By default, the schema exposes a `create`, `update` and `delete` operation for each class, for example, `create_User`, `update_User` and `delete_User`. You can disable any of these mutations for any class in your schema, like so:
@@ -243,3 +270,20 @@ By default, the schema exposes a `create`, `update` and `delete` operation for e
243270
```
244271

245272
**Note**: the `delete` mutation setting key is named `destroy` to avoid issues due to `delete` being a javascript reserved word.
273+
274+
You can optionally override the default generated mutation names with aliases:
275+
276+
```javascript
277+
{
278+
"classConfigs": [
279+
{
280+
"className": "Record",
281+
"mutation": {
282+
"createAlias": "newRecord",
283+
"updateAlias": "changeRecord",
284+
"destroyAlias": "eraseRecord"
285+
}
286+
}
287+
]
288+
}
289+
```

0 commit comments

Comments
 (0)