0.2.0 • Published 4 years ago

@jcm/nexus-plugin-relay-mutation v0.2.0

Weekly downloads
150
License
MIT
Repository
-
Last release
4 years ago

@jcm/nexus-plugin-relay-mutation

This plugin adds the field method relayMutation(fieldName, fieldConfig) to the Nexus Schema Builder, which can be used to create Relay-compliant mutations.

It's based on the mutation helper from graphql-relay.

Sample usage:

const mutation = mutationField((t) => {
  t.relayMutation('addNumbers', {
    inputFields(t2) {
      t2.int('number1', {
        required: true,
      })
      t2.int('number2', {
        required: true,
      })
    },
    outputFields(t2) {
      t2.int('result')
    },
    mutateAndGetPayload(_root, input, _ctx, _info) {
      return {
        result: input.number1 + input.number2,
      }
    },
  })
})

With the above code, the following schema will be generated:

input addNumbersInput {
  number1: Int!
  number2: Int!
  clientMutationId: String
}

type addNumbersPayload {
  result: Int!
  clientMutationId: String
}

type Mutation {
  addNumbers(input: addNumbersInput!): addNumbersPayload!
  # ...
}

# ...
0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago