API

mutationField

mutationField

Mutations are usually best split up, and are one of the most common use-cases for extendType. mutationField exists as a shorthand for this common case:

1export const createUser = mutationField('createUser', {
2 type: SomeType,
3 resolve() {
4 // ...
5 },
6})

as shorthand for:

1export const createUser = extendType({
2 type: "Mutation",
3 definition(t) {
4 t.field('createUser', {
5 type: SomeType
6 resolve() {
7 // ...
8 }
9 })
10 }
11})

You can also use it with a function as the first argument, which will pass the t provided to the definition block, especially useful when using with the connection plugin:

1export const usersQueryField = mutationField((t) => {
2 t.connectionField('updateUsersList', {
3 type: SomeType,
4 resolve() {
5 // ...
6 },
7 })
8})
Edit this page on Github