Skip to content

Commit

Permalink
Docs for GQL query and mutation aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
BufferUnderflower authored Dec 4, 2019
1 parent 5a685ad commit 557459a
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion _includes/graphql/customisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ interface ParseGraphQLConfiguration {
query?: {
get?: boolean;
find?: boolean;
getAlias?: String;
findAlias?: String;
};

// By default, all write mutation types are
// exposed for all included classes. Use this to disable
// the available mutation types for this class.
// the available mutation types for this class and optionally
// override the default generated name with aliases.
mutation?: {
create?: boolean;
update?: boolean;
destroy?: boolean;
createAlias?: String,
updateAlias?: String,
destroyAlias?: String,
};
}>
}
Expand Down Expand Up @@ -214,6 +220,27 @@ By default, the schema exposes a `get` and `find` operation for each class, for
}
```

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`:

```javascript
{
"classConfigs": [
{
"className": "Likes",
"query": {
"getAlias": "like"
}
},
{
"className": "Data",
"query": {
"findAlias": "findData"
}
}
]
}

```
### Mutations

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:
Expand Down Expand Up @@ -243,3 +270,20 @@ By default, the schema exposes a `create`, `update` and `delete` operation for e
```

**Note**: the `delete` mutation setting key is named `destroy` to avoid issues due to `delete` being a javascript reserved word.

You can optionally override the default generated mutation names with aliases:

```javascript
{
"classConfigs": [
{
"className": "Record",
"mutation": {
"createAlias": "newRecord",
"updateAlias": "changeRecord",
"destroyAlias": "eraseRecord"
}
}
]
}
```

0 comments on commit 557459a

Please sign in to comment.