How to use the apollo-server-errors.fromGraphQLError function in apollo-server-errors

To help you get started, we’ve selected a few apollo-server-errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
.catch(executionError => {
            return {
              // These errors will get passed through formatApolloErrors in the
              // `then` below.
              // TODO accurate code for this error, which describes this error, which
              // can occur when:
              // * variables incorrectly typed/null when nonnullable
              // * unknown operation/operation name invalid
              // * operation type is unsupported
              // Options: PREPROCESSING_FAILED, GRAPHQL_RUNTIME_CHECK_FAILED

              errors: [fromGraphQLError(executionError)],
            } as ExecutionResult;
          })
          .then(result => {
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
.catch(executionError => {
            return {
              // These errors will get passed through formatApolloErrors in the
              // `then` below.
              // TODO accurate code for this error, which describes this error, which
              // can occur when:
              // * variables incorrectly typed/null when nonnullable
              // * unknown operation/operation name invalid
              // * operation type is unsupported
              // Options: PREPROCESSING_FAILED, GRAPHQL_RUNTIME_CHECK_FAILED

              errors: [fromGraphQLError(executionError)],
            } as ExecutionResult;
          })
          .then(result => {
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
validationErrors.map(err =>
                  fromGraphQLError(err, { errorClass: ValidationError }),
                ),
github apollographql / apollo-server / packages / apollo-server-core / src / requestPipeline.ts View on Github external
errors.map(err =>
          fromGraphQLError(
            err,
            errorClass && {
              errorClass,
            },
          ),
        ),
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
let documentAST: DocumentNode;
        if (options.parsedQuery) {
          documentAST = options.parsedQuery;
        } else if (!options.queryString) {
          throw new Error('Must supply one of queryString and parsedQuery');
        } else {
          const parsingDidEnd = extensionStack.parsingDidStart({
            queryString: options.queryString,
          });
          let graphqlParseErrors: SyntaxError[] | undefined;
          try {
            documentAST = parse(options.queryString);
          } catch (syntaxError) {
            graphqlParseErrors = formatApolloErrors(
              [
                fromGraphQLError(syntaxError, {
                  errorClass: SyntaxError,
                }),
              ],
              {
                debug,
              },
            );
            return Promise.resolve({ errors: graphqlParseErrors });
          } finally {
            parsingDidEnd(...(graphqlParseErrors || []));
          }
        }

        if (
          options.nonQueryError &&
          !isQueryOperation(documentAST, options.operationName)
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
validationErrors.map(err =>
                  fromGraphQLError(err, { errorClass: ValidationError }),
                ),
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
let documentAST: DocumentNode;
        if (options.parsedQuery) {
          documentAST = options.parsedQuery;
        } else if (!options.queryString) {
          throw new Error('Must supply one of queryString and parsedQuery');
        } else {
          const parsingDidEnd = extensionStack.parsingDidStart({
            queryString: options.queryString,
          });
          let graphqlParseErrors: SyntaxError[] | undefined;
          try {
            documentAST = parse(options.queryString);
          } catch (syntaxError) {
            graphqlParseErrors = formatApolloErrors(
              [
                fromGraphQLError(syntaxError, {
                  errorClass: SyntaxError,
                }),
              ],
              {
                debug,
              },
            );
            return Promise.resolve({ errors: graphqlParseErrors });
          } finally {
            parsingDidEnd(...(graphqlParseErrors || []));
          }
        }

        if (
          options.nonQueryError &&
          !isQueryOperation(documentAST, options.operationName)