Graphql: Error Module Cheat Sheet

GraphQLError 

A representation of an error that occurred within GraphQL.

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

syntaxError 

Produces a GraphQLError representing a syntax error.

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

locatedError 

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

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

formatError 

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 *