UNPKG

graphql

Version:

A Query Language and Runtime which can target any service.

1 lines 1.47 kB
{"version":3,"file":"syntaxError.js","sourceRoot":"","sources":["../../src/error/syntaxError.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,2BAA0B;AAoBjD,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,QAAgB,EAChB,WAAmB;IAEnB,OAAO,IAAI,YAAY,CAAC,iBAAiB,WAAW,EAAE,EAAE;QACtD,MAAM;QACN,SAAS,EAAE,CAAC,QAAQ,CAAC;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["/** @category Errors */\n\nimport type { Source } from '../language/source.ts';\n\nimport { GraphQLError } from './GraphQLError.ts';\n\n/**\n * Produces a GraphQLError representing a syntax error, containing useful\n * descriptive information about the syntax error's position in the source.\n * @param source - The GraphQL source containing the syntax error.\n * @param position - Character offset where the syntax error was encountered.\n * @param description - Human-readable description of the syntax error.\n * @returns A GraphQLError located at the syntax error position.\n * @example\n * ```ts\n * import { Source } from 'graphql/language';\n * import { syntaxError } from 'graphql/error';\n *\n * const error = syntaxError(new Source('query {'), 7, 'Expected Name');\n *\n * error.message; // => 'Syntax Error: Expected Name'\n * error.locations; // => [{ line: 1, column: 8 }]\n * ```\n */\nexport function syntaxError(\n source: Source,\n position: number,\n description: string,\n): GraphQLError {\n return new GraphQLError(`Syntax Error: ${description}`, {\n source,\n positions: [position],\n });\n}\n"]}