gatsbyjs/gatsby · error

stringifiedErrors

Error message

stringifiedErrors

What it means

When throwGqlErrors is true and the WPGraphQL response carries a `data.errors` array, fetch-graphql joins every error message with double newlines and throws the resulting string. This surfaces raw GraphQL validation/runtime errors (e.g. 'Cannot query field X on type Y') as a single Error. It only fires when the caller explicitly opts into throwing GraphQL errors rather than the default handleGraphQLErrors reporting path.

Source

Thrown at packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts:812

      e,
      reporter,
      url,
      timeout,
      variables,
      pluginOptions,
      query,
      response,
      errorContext,
      isFirstRequest,
    })
  }

  if (throwGqlErrors && response.data.errors) {
    const stringifiedErrors: string = response.data.errors
      .map((error: { message: string }) => error.message)
      .join(`\n\n`)

    throw new Error(stringifiedErrors)
  }

  if (!ignoreGraphQLErrors) {
    await handleGraphQLErrors({
      query,
      variables,
      response,
      errorMap,
      panicOnError,
      reporter,
      errorContext,
      forceReportCriticalErrors,
    })
  }

  return response?.data
}

View on GitHub (pinned to 8b06340921)

Solutions

  1. Read the thrown message — it lists every GraphQL error verbatim; fix the offending query/field.
  2. If the schema changed, regenerate introspection and update any custom queries in pluginOptions.
  3. Re-authenticate if the errors are permission-related (htaccess credentials or WPGraphQL JWT).
  4. If errors are spurious, clear the WPGraphQL schema cache on the WordPress side.

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

function hasGqlErrors(r): r is { data: { errors: Array<{ message: string }> } } { return r && Array.isArray(r.data?.errors) && r.data.errors.length > 0 }

Try / catch

try { await fetchGraphQL({ ...opts, throwGqlErrors: true }) } catch (e) { if (/Cannot query field|Field .* doesn't exist/.test(e.message)) { reporter.warn(`Schema mismatch from WPGraphQL: ${e.message}`) } throw e }

Prevention

When it happens

Trigger: A query references a field that does not exist in the WPGraphQL schema; a WPGraphQL permission error on a field; type mismatch in a mutation; schema drift after WPGraphQL version upgrade removed/renamed fields.

Common situations: WPGraphQL upgraded and a field was removed/renamed; custom WPGraphQL fields unavailable because the extending plugin was deactivated; querying private fields without authentication; schema cache stale after a WordPress post type change.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/88c854ea9e51547d. Report an issue: GitHub.