🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
Require Field of Type Query in Mutation Result

require-field-of-type-query-in-mutation-result

  • Category: Schema
  • Rule name: @graphql-eslint/require-field-of-type-query-in-mutation-result
  • Requires GraphQL Schema: true ℹī¸
  • Requires GraphQL Operations: false ℹī¸

Allow the client in one round-trip not only to call mutation but also to get a wagon of data to update their application.

Currently, no errors are reported for result type union, interface and scalar.

Usage Examples

Incorrect

# eslint @graphql-eslint/require-field-of-type-query-in-mutation-result: 'error'
 
type User { ... }
 
type Mutation {
  createUser: User!
}

Correct

# eslint @graphql-eslint/require-field-of-type-query-in-mutation-result: 'error'
 
type User { ... }
 
type Query { ... }
 
type CreateUserPayload {
  user: User!
  query: Query!
}
 
type Mutation {
  createUser: CreateUserPayload!
}

Resources