Skip to content
This repository was archived by the owner on Mar 15, 2023. It is now read-only.

Latest commit

 

History

History
48 lines (35 loc) · 1.14 KB

mutations-input-type.md

File metadata and controls

48 lines (35 loc) · 1.14 KB

Mutations must take single input types (mutation-input-type)

All mutations must take no arguments or a single non-nullable argument named input of a type with the suffix Input.

Rule Details

Best practice is to have a unique Input type for every mutation. This is easier to use on the client side and allows us to add new fields to a mutation input without breaking the API.

If a mutation really doesn't need arguments (eg only needs domain/user from the login context) that's fine too.

Autofixer not available.

Examples of incorrect code for this rule:

type Mutation {
  sampleMutation(arg1: Int, arg2: String): SampleMutationPayload
}
type Mutation {
  sampleMutation(input: [SampleMutationInput]): SampleMutationPayload
}
type Mutation {
  sampleMutation(parameters: SampleMutationInput!): SampleMutationPayload
}

Examples of correct code for this rule:

type Mutation {
  sampleMutation(input: SampleMutationInput!): SampleMutationPayload
  arglessMutation: ArglessMutationPayload
}

When Not To Use It

If you have a mutation that you're sure will never need to change.