After having upgraded to version 2.1.33 of gatsby-source-graphql I'm getting an error when trying to query. Error does not occur in versions of the plugin using graphql-tools rather than graphql-tools-fork (ex.: previous version used was 2.1.15). The graphql source in this case is an AWS AppSync endpoint. A test call to the endpoint with the parameters set in the gatsby-config.js file returns a successful response.
gatsby-config.js
{
resolve: `gatsby-source-graphql`,
options: {
typeName: 'Book',
fieldName: 'catalogue',
url: 'https://xxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',
headers: {
'x-api-key': 'xxxxxx'
}
}
}
Upon navigating to the graphql console at http://localhost:8000/___graphql and trying to run a query against the fieldName, the following error result occurs:
{
"errors": [
{
"message": "context is not defined",
"locations": [
{
"line": 7,
"column": 5
}
],
"path": [
"catalogue",
"listBooks"
],
"stack": [
"ReferenceError: context is not defined",
" at buildDelegationTransforms (/Users/steve/Source/catalogue/node_modules/graphql-tools-fork/dist/stitching/delegateToSchema.js:48:98)",
" at delegateRequest (/Users/steve/Source/catalogue/node_modules/graphql-tools-fork/dist/stitching/delegateToSchema.js:75:32)",
" at Object.delegateToSchema [as default] (/Users/steve/Source/catalogue/node_modules/graphql-tools-fork/dist/stitching/delegateToSchema.js:40:12)",
" at /Users/steve/Source/catalogue/node_modules/graphql-tools-fork/dist/stitching/resolvers.js:57:86",
" at resolveFieldValueOrError (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:467:18)",
" at resolveField (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:434:16)",
" at executeFields (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:275:18)",
" at collectAndExecuteSubfields (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:713:10)",
" at completeObjectValue (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:703:10)",
" at completeValue (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:591:12)",
" at completeValue (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:557:21)",
" at completeValueCatchingError (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:495:19)",
" at resolveField (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:435:10)",
" at executeFields (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:275:18)",
" at executeOperation (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:219:122)",
" at executeImpl (/Users/steve/Source/catalogue/node_modules/graphql/execution/execute.js:104:14)"
]
}
],
"data": {
"graphQlSource": {
"fieldName": "catalogue",
"typeName": "Book"
},
"catalogue": {
"listBooks": null
}
}
}
The query should return data from the graphql source, which it does when an older version of the package is used.
"context is not defined" error is returned
System:
OS: macOS 10.15.2
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Shell: 5.7.1 - /usr/local/bin/zsh
Binaries:
Node: 10.18.1 - /usr/local/opt/node@10/bin/node
npm: 6.13.4 - /usr/local/opt/node@10/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 79.0.3945.130
Safari: 13.0.4
npmPackages:
gatsby: ^2.19.12 => 2.19.12
gatsby-image: ^2.2.40 => 2.2.40
gatsby-plugin-manifest: ^2.2.41 => 2.2.41
gatsby-plugin-offline: ^3.0.34 => 3.0.34
gatsby-plugin-react-helmet: ^3.1.22 => 3.1.22
gatsby-plugin-sharp: ^2.4.5 => 2.4.5
gatsby-source-filesystem: ^2.1.48 => 2.1.48
gatsby-source-graphql: ^2.1.33 => 2.1.33
gatsby-transformer-sharp: ^2.3.14 => 2.3.14
npmGlobalPackages:
gatsby-cli: 2.8.28
I also am experiencing this issue. I went on a downgrading spree and version 2.1.29 was the version that fixed it for me.
Edit: it seems like the package-lock tells a bit of the story.

Version 2.1.30 was the version where graphql-tools-fork went from 7 to 8
I can confirm that the downgrade to 2.1.29 fixed the issue. Maybe @yaacovCR has an idea of what's happening here?
Poor linting. Should be able to fix overnight (US Eastern). Anybody who can give me some guidance on the underlying lint failure, would be much appreciated.
Should be fixed by v8.5.1.
@stevebreault Can you confirm that upstream fixes in graphql-tools-fork fixed it for you? If it is the case then we can close this.
@vladar I added [email protected] as a dependency after re-upgrading to [email protected] and can confirm that the fixes there resolve the issue.
Here's my output of npm list that confirms the package versions used:
โถ npm list --depth=0
[email protected] /Users/steve/Source/catalogue
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
Feel free to reopen if you hit this again, closing for now, latest versions of graphql-tools-fork use eslint rules which only enable mocha environment in test files so that this can be avoided.
Most helpful comment
Should be fixed by v8.5.1.