gatsby: gatsby-source-graphql > 2.1.29: schema.getDirectives is not a function
Description
Encountered schema.getDirectives is not a function
using gatsby-source-graphql@2.1.33.
The issue seems to be with dependency graphql-tool-fork@8.
Using gatsby-source-graphql@2.1.29 which depends on graphql-tool-fork@7 is how I worked around this issue.
Steps to reproduce
# clone repo
git clone https://github.com/lablancas/gatsby-reproduce-bug.git
cd gatsby-reproduce-bug
# edit .env.development to connect to your GraphQL server
# install dependencies and start gatsby
yarn
gatsby develop
Expected result
Gatsby development server starts without error and lineups
node has been successfully created
Open http://localhost:8000/___graphql and run
query {
lineups {
__typename
}
}
Response should be
{
"data": {
"lineups": {
"__typename": "Lineups"
}
}
}
Actual result
Gatsby server log has an error TypeError: schema.getDirectives is not a function
and lineups
node was not created
GraphQL response from the query above is
{
"errors": [
{
"message": "Cannot query field \"lineups\" on type \"Query\".",
"locations": [
{
"line": 3,
"column": 3
}
],
"stack": [
"GraphQLError: Cannot query field \"lineups\" on type \"Query\".",
" at Object.Field (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/graphql/language/visitor.js:242:26)",
" at validate (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/graphql/validation/validate.js:73:24)",
" at getGraphQLParams.then.then.optionsData (/Users/lucas/Development/lineups/gatsby-reproduce-bug/node_modules/express-graphql/index.js:121:32)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
]
}
Environment
System: OS: macOS 10.15.3 CPU: x64 Intel® Core™ i5-7360U CPU @ 2.30GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 10.17.0 - ~/.nvm/versions/node/v10.17.0/bin/node Yarn: 1.22.0 - ~/.yvm/shim/yarn npm: 6.11.3 - ~/.nvm/versions/node/v10.17.0/bin/npm Browsers: Chrome: 79.0.3945.130 Safari: 13.0.5 npmPackages: gatsby: ^2.19.7 => 2.19.7 gatsby-image: ^2.2.39 => 2.2.39 gatsby-plugin-manifest: ^2.2.39 => 2.2.39 gatsby-plugin-offline: ^3.0.32 => 3.0.32 gatsby-plugin-react-helmet: ^3.1.21 => 3.1.21 gatsby-plugin-sharp: ^2.4.3 => 2.4.3 gatsby-source-filesystem: ^2.1.46 => 2.1.46 gatsby-source-graphql: ^2.1.33 => 2.1.33 gatsby-transformer-sharp: ^2.3.13 => 2.3.13
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 31 (9 by maintainers)
Commits related to this issue
- fix graphql-source-plugin version to avoid https://github.com/gatsbyjs/gatsby/issues/21443 — committed to fireblogcms/gatsby-starter-fireblog-basic by yann-yinn 4 years ago
- fix(transformSchema): handle schemaConfig objects Regression caused by https://github.com/yaacovCR/graphql-tools-fork/commit/3c3a256feddca731be25315cb7a5ab0f45bd5c4a. Fixes https://github.com/gatsby... — committed to yaacovCR/graphql-tools-fork by yaacovCR 4 years ago
- fix(transformSchema): handle schemaConfig objects Regression caused by https://github.com/yaacovCR/graphql-tools-fork/commit/3c3a256feddca731be25315cb7a5ab0f45bd5c4a. Fixes https://github.com/gatsby... — committed to yaacovCR/graphql-tools-fork by yaacovCR 4 years ago
- fix(transformSchema): handle schemaConfig objects Regression caused by https://github.com/yaacovCR/graphql-tools-fork/commit/3c3a256feddca731be25315cb7a5ab0f45bd5c4a. Fixes https://github.com/gatsby... — committed to yaacovCR/graphql-tools-fork by yaacovCR 4 years ago
- fix(transformSchema): handle schemaConfig objects Regression caused by https://github.com/yaacovCR/graphql-tools-fork/commit/3c3a256feddca731be25315cb7a5ab0f45bd5c4a. Fixes https://github.com/gatsby... — committed to yaacovCR/graphql-tools-fork by yaacovCR 4 years ago
hey everybody, I keep getting the error
despite trying versions: “gatsby-source-graphql”: “2.1.28” “gatsby-source-graphql”: “2.1.29” “gatsby-source-graphql”: “2.1.32”
Please let me know if you need further context. thanks!
See #23002
Should be fixed by graphql-tools-fork v8.5.5.
Apologies for regression. If you can verify this has been fixed with v8.5.5 after unpinning v8.5.4, should be able to close.
Thanks so much @narration-sd you just saved me hours of debugging.
package-lock.json
Running ‘gatsby build’ with the above settings gives the same error as the image. If you run
gatsby build
after restoring to the following settings, no error will occur. What is the problem?backup package-lock.json
And thanks a lot @yaacovCR for taking care of this!
Sorry you had to hit this. Must be very frustrating.
Must be something in graphql-tools-fork patch revision to 8.5.4.
That was about switching to eslint to avoid problems like #21170 .
Do you have a stack trace handy.
Hopeful I can dig into this soon.
The trick of it is that it isn’t the plugin that changed – the latest was 13 days ago.
It’s something it doesn’t get along with now, perhaps a library that summarily changed its interface.
You have to wonder where testing was on this one, don’t you…
@roryashfordbentley Most welcome, but it was really just close reading of @lablancas’ report, trying what he found and said 🙂
I can confirm this error using the following steps:
Having the same error with v.2.1.33, v.2.1.32, v.2.1.31. Confirmed working with v.2.1.28.
Confirmed – thanks, @lablancas.
I have just the same error, on two separate long-term projects, data from two quite differing GraphQL servers.
Running gatsby-source-graphql back to 2.1.29 recovers operation.
$ npm run build
success open and validate gatsby-configs - 0.063s success load plugins - 1.972s success onPreInit - 0.005s success delete html and css files from previous builds - 0.011s success initialize cache - 0.022s success copy gatsby files - 0.232s success onPreBootstrap - 0.019s success createSchemaCustomization - 0.006s
ERROR #11321 PLUGIN
“gatsby-source-graphql” threw an error while running the sourceNodes lifecycle:
schema.getDirectives is not a function
99 | }; 100 |
File: node_modules\gatsby-source-graphql\gatsby-node.js:101:18
not finished source and transform nodes - 2.410s npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! gatsby-starter-default@1.0.0 build:
gatsby build
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the gatsby-starter-default@1.0.0 build script.