{"record":{"id":"562b00031c3fa71c","repo":"gatsbyjs/gatsby","slug":"graphql-request-returned-an-empty-string","errorCode":null,"errorMessage":"GraphQL request returned an empty string.","messagePattern":"GraphQL request returned an empty string\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts","lineNumber":768,"sourceCode":"        moduleHelpers\n          .getHttp(limit)\n          .post(url, { query, variables }, requestOptions)\n          .catch(e => {\n            if (!errorIs500ish(e)) {\n              // for any error that is not a 50x error, we bail, meaning we stop retrying. error will be thrown one level higher\n              bail(e)\n\n              return null\n            } else {\n              // otherwise throwing the error will cause the retry to happen again\n              throw e\n            }\n          }),\n      { retries: 5 }\n    )\n\n    if (response.data === ``) {\n      throw new Error(`GraphQL request returned an empty string.`)\n    }\n\n    const { path }: { path: string } = urlUtil.parse(url)\n\n    const responsePath = response.request.path\n\n    if (\n      path !== responsePath &&\n      responsePath !== undefined &&\n      responsePath !== url\n    ) {\n      throw new Error(`GraphQL request was redirected to ${responsePath}`)\n    }\n\n    const contentType: string = response.headers[`content-type`]\n\n    if (!contentType.includes(`application/json;`)) {\n      throw new Error(`Unable to connect to WPGraphQL.`)","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts#L750-L786","documentation":"After the retry loop completes, fetch-graphql checks that response.data is not an empty string. WPGraphQL should always return a JSON body; an empty body indicates the endpoint returned nothing (server crash, proxy interception, wrong URL returning a 200 with empty body). This is distinct from a network error (which the retry/bail handles) — the HTTP call succeeded but produced no data.","triggerScenarios":"WPGraphQL endpoint URL points to a plain page that returns an empty 200; PHP fatal error before WPGraphQL runs, returning empty body; a caching layer returning an empty cached response; URL is correct host but wrong path.","commonSituations":"WPGraphQL plugin not activated (server returns the WP homepage HTML, but here the empty-string branch fires when the body is literally empty); reverse proxy stripping the body; misconfigured url in pluginOptions; server-side fatal during the GraphQL request.","solutions":["Curl the GraphQL endpoint with the same query: curl -X POST <url> -H 'Content-Type: application/json' -d '{\"query\":\"{generalSettings{url}}\"}' and inspect the raw body.","Confirm WPGraphQL (and WPGatsby) are activated on the WordPress side.","Verify pluginOptions.url points to the GraphQL endpoint (typically /graphql), not the site root.","Check PHP error logs on the WordPress server for fatal errors during the request."],"exampleFix":"// before\nurl: `https://wp.example.com`\n\n// after\nurl: `https://wp.example.com/graphql`","handlingStrategy":"try-catch","validationCode":"const probe = await axios.post(url, { query: '{generalSettings{url}}' })\nif (probe.data === '') { throw new Error('Endpoint returned empty body; check WPGraphQL activation and url') }","typeGuard":"null","tryCatchPattern":"try { await fetchGraphQL(opts) } catch (e) { if (/empty string/.test(e.message)) { reporter.panic('WPGraphQL returned an empty body; verify url and plugin activation') } throw e }","preventionTips":["Probe the GraphQL endpoint with curl before running the build","Confirm WPGraphQL and WPGatsby are activated","Set the correct /graphql path in pluginOptions.url","Monitor PHP error logs for fatal errors"],"tags":["wordpress","graphql","network","config"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}