From cca71cfb32b295e6feeed19a4103f27e3aeed2c0 Mon Sep 17 00:00:00 2001 From: dhoko Date: Fri, 28 May 2021 19:41:31 +0200 Subject: [PATCH] feat(gatsby-source-wordpress): Fix false positive error if the URL and the responsePath are the same (#31612) It is possible to get this output from the response: { responsePath: 'https:///graphql', path: '/graphql', url: 'https:///graphql' } instead of { responsePath: '/graphql', path: '/graphql', url: 'https:///graphql' } It doesn't make sense to reject the request with GraphQL request was redirected as the responsePath _is_ the url. --- packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts b/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts index a33d696b5f851..272dc4f71a335 100644 --- a/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts +++ b/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts @@ -745,7 +745,11 @@ const fetchGraphql = async ({ const responsePath = response.request.path - if (path !== responsePath && responsePath !== undefined) { + if ( + path !== responsePath && + responsePath !== undefined && + responsePath !== url + ) { throw new Error(`GraphQL request was redirected to ${responsePath}`) }