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

Latest commit

 

History

History
49 lines (36 loc) · 959 Bytes

payloads-are-unions.md

File metadata and controls

49 lines (36 loc) · 959 Bytes

Payloads are unions of a success type and one or more error types (payloads-are-unions)

A mutation payload must contain a unique success object type with the suffix Success, the base error type BaseUserError, and zero or more specific error types.

Rule Details

Autofixer not available.

Examples of incorrect code for this rule:

type Mutation {
  sampleMutation: SampleMutationPayload
}

type SampleMutationPayload {
  result: String
}
type Mutation {
  sampleMutation: SampleMutationPayload
}

union SampleMutationPayload = String | BaseUserError
type Mutation {
  sampleMutation: SampleMutationPayload
}

union SampleMutationPayload = MutationSuccess | Int

Examples of correct code for this rule:

type Mutation {
  register(input: RegisterInput!): RegisterPayload
}

union RegisterPayload =
    RegisterSuccess
  | BaseUserError
  | InvalidEmailError
  | PasswordTooWeakError