Graphql: Error Module Cheat Sheet


A representation of an error that occurred within GraphQL.

class GraphQLError extends Error {
   message: string,
   nodes?: Array<any>,
   stack?: ?string,
   source?: Source,
   positions?: Array<number>,
   originalError?: ?Error,
   extensions?: ?{ [key: string]: mixed }


Produces a GraphQLError representing a syntax error.

function syntaxError(
  source: Source,
  position: number,
  description: string
): GraphQLError;


Produces a new GraphQLError aware of the location responsible for the error.

function locatedError(error: ?Error, nodes: Array<any>): GraphQLError {


Format an error according to the rules described by the Response Format.

function formatError(error: GraphQLError): GraphQLFormattedError

type GraphQLFormattedError = {
  message: string,
  locations: ?Array<GraphQLErrorLocation>

type GraphQLErrorLocation = {
  line: number,
  column: number

Leave a Reply

Your email address will not be published. Required fields are marked *