{"record":{"id":"fe1e863237018da4","repo":"anuraghazra/github-readme-stats","slug":"graphql-error","errorCode":"GRAPHQL_ERROR","errorMessage":"Something went wrong while trying to retrieve the stats data using the GraphQL API.","messagePattern":"Something went wrong while trying to retrieve the stats data using the GraphQL API\\.","errorType":"error_code","errorClass":"CustomError","httpStatus":null,"severity":"error","filePath":"src/fetchers/stats.js","lineNumber":278,"sourceCode":"    startTime: commits_year ? `${commits_year}-01-01T00:00:00Z` : undefined,\n  });\n\n  // Catch GraphQL errors.\n  if (res.data.errors) {\n    logger.error(res.data.errors);\n    if (res.data.errors[0].type === \"NOT_FOUND\") {\n      throw new CustomError(\n        res.data.errors[0].message || \"Could not fetch user.\",\n        CustomError.USER_NOT_FOUND,\n      );\n    }\n    if (res.data.errors[0].message) {\n      throw new CustomError(\n        wrapTextMultiline(res.data.errors[0].message, 90, 1)[0],\n        res.statusText,\n      );\n    }\n    throw new CustomError(\n      \"Something went wrong while trying to retrieve the stats data using the GraphQL API.\",\n      CustomError.GRAPHQL_ERROR,\n    );\n  }\n\n  const user = res.data.data.user;\n\n  stats.name = user.name || user.login;\n\n  // if include_all_commits, fetch all commits using the REST API.\n  if (include_all_commits) {\n    stats.totalCommits = await totalCommitsFetcher(username);\n  } else {\n    stats.totalCommits = user.commits.totalCommitContributions;\n  }\n\n  stats.totalPRs = user.pullRequests.totalCount;\n  if (include_merged_pull_requests) {","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/stats.js#L260-L296","documentation":"CustomError(GRAPHQL_ERROR) thrown by fetchStats as the final fallback inside the 'res.data.errors' block: errors exist, the first error's type is not NOT_FOUND, and its message is empty/falsy. The message is a fixed 'Something went wrong while trying to retrieve the stats data using the GraphQL API.' and the secondary message is 'Please try again later'. It is a catch-all for malformed/empty GraphQL error objects.","triggerScenarios":"The stats GraphQL response carries an errors array whose first element has neither type === 'NOT_FOUND' nor a usable message — e.g. GitHub returned an errors entry with only a path/locations field, or an empty-string message. The two earlier if-checks (NOT_FOUND, then non-empty message) both fall through, landing here.","commonSituations":"A transient GitHub GraphQL hiccup returning a minimal/empty error object; a response shape change where the message field is absent; or an intermediary (proxy/cache) stripping error fields. Rare and non-deterministic.","solutions":["Retry the request — the secondary message explicitly says 'try again later'.","If persistent, log res.data.errors fully to see what GitHub actually returned.","Check GitHub API status and the configured token's validity/scopes.","Confirm no proxy/cache layer is mangling the GraphQL response."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// GRAPHQL_ERROR is the documented transient fallback; retry with backoff.\ntry {\n  return await fetchStats(username);\n} catch (err) {\n  if (err.type === CustomError.GRAPHQL_ERROR) {\n  await new Promise((r) => setTimeout(r, 5_000));\n    return fetchStats(username);\n  }\n  throw err;\n}","preventionTips":["Treat GRAPHQL_ERROR as transient by default — the secondary message says 'try again later'.","Log the full res.data.errors when it recurs, since the thrown message is generic by design."],"tags":["stats","graphql","fallback","transient","github-api"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}