How to use the apollo-server-errors.hasPersistedQueryError 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 / runHttpQuery.ts View on Github external
export function throwHttpGraphQLError(
  statusCode: number,
  errors: Array,
  options?: Pick,
  extensions?: GraphQLExecutionResult['extensions'],
): never {
  const defaultHeaders = { 'Content-Type': 'application/json' };
  // force no-cache on PersistedQuery errors
  const headers = hasPersistedQueryError(errors)
    ? {
        ...defaultHeaders,
        'Cache-Control': 'private, no-cache, must-revalidate',
      }
    : defaultHeaders;

  type Result =
   & Pick
   & { errors: E[] | ApolloError[] }

  const result: Result = {
    errors: options
      ? formatApolloErrors(errors, {
          debug: options.debug,
          formatter: options.formatError,
        })