gatsby-source-graphql@2.2.1 throws error: Cannot use GraphQLDirective "@include" from another module or realm
See original GitHub issueDescription
While deploying a new site version where CI runs its own build for deployment, I am now running into a new error. When running gatsby develop
, as it runs though plugin initialization, I am now getting the following error:
"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:
Cannot use GraphQLDirective "@include" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
74 | if (!sdl) {
75 | introspectionSchema = await introspectSchema(link);
> 76 | sdl = printSchema(introspectionSchema);
| ^
77 | } else {
78 | introspectionSchema = buildSchema(sdl);
79 | }
File: node_modules/gatsby-source-graphql/gatsby-node.js:76:13
Which is followed by the following warning:
Error: Cannot use GraphQLDirective "@include" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
Previous to this, the project was running gatsby-source-graphql@2.1.33. Downgrade is however not fixing the issue.
Steps to reproduce
List of installed dependencies, updated from hello-world starter:
βββ @appbaseio/reactivesearch@3.7.1
βββ @aws-amplify/api@2.2.0
βββ @aws-amplify/auth@2.1.7
βββ @aws-amplify/pubsub@1.3.3
βββ @fortawesome/fontawesome-svg-core@1.2.28
βββ @fortawesome/free-brands-svg-icons@5.13.0
βββ @fortawesome/free-solid-svg-icons@5.13.0
βββ @fortawesome/pro-regular-svg-icons@5.13.0
βββ @fortawesome/react-fontawesome@0.1.9
βββ @tailwindcss/custom-forms@0.2.1
βββ gatsby@2.20.8
βββ gatsby-image@2.3.1
βββ gatsby-plugin-manifest@2.3.3
βββ gatsby-plugin-offline@3.1.2
βββ gatsby-plugin-postcss@2.2.1
βββ gatsby-plugin-react-helmet@3.2.1
βββ gatsby-plugin-sharp@2.5.3
βββ gatsby-source-filesystem@2.2.2
βββ gatsby-source-graphql@2.2.1
βββ gatsby-transformer-sharp@2.4.3
βββ prettier@2.0.2
βββ prop-types@15.7.2
βββ react@16.13.1
βββ react-dom@16.13.1
βββ react-headroom@3.0.0
βββ react-helmet@5.2.1
βββ tailwindcss@1.2.0
βββ uuid@7.0.2
Configuration of plugin in gatsy-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'
}
}
}
Expected result
Previously, the plugin would run without issue and create the source nodes successfully
Actual result
When the plugin is initialized, it throws the error above.
Environment
System:
OS: macOS 10.15.3
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Shell: 5.8 - /usr/local/bin/zsh
Binaries:
Node: 10.19.0 - /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: 80.0.3987.149
Safari: 13.0.5
npmPackages:
gatsby: ^2.20.8 => 2.20.8
gatsby-image: ^2.3.1 => 2.3.1
gatsby-plugin-manifest: ^2.3.3 => 2.3.3
gatsby-plugin-offline: ^3.1.2 => 3.1.2
gatsby-plugin-postcss: ^2.2.1 => 2.2.1
gatsby-plugin-react-helmet: ^3.2.1 => 3.2.1
gatsby-plugin-sharp: ^2.5.3 => 2.5.3
gatsby-source-filesystem: ^2.2.2 => 2.2.2
gatsby-source-graphql: ^2.3.0 => 2.3.0
gatsby-transformer-sharp: ^2.4.3 => 2.4.3
npmGlobalPackages:
gatsby-cli: 2.8.28
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Error: Cannot use GraphQLObjectType "__Directive" from ...
Error : Cannot use GraphQLObjectType "__Directive" from another module or realm . Ensure that there is only one instance of "graphql" in theΒ ......
Read more >Frequently Asked Questions - TypeGraphQL
Cannot use GraphQLSchema "[object Object]" from another module or realm. This error occurs mostly when there are more than one version of the...
Read more >Cannot use GraphQLObjectType "__Directive" from another ...
I get this error: β Cannot use GraphQLObjectType "__Directive" from another module or realm. Ensure that there is only one instance ofΒ ...
Read more >graphql - UNPKG
34, throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm. 35. 36, Ensure that there is only one instance of "graphql"Β ......
Read more >Error Cannot use GraphQLScalarType [*Type*] from another ...
I am trying to use apollo:codegen to generate schema and ... Error Cannot use GraphQLScalarType [*Type*] from another module or realm.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I get the same error whith the following
npm ls graphql
resolved it with https://github.com/birkir/gatsby-source-graphql-universal/issues/14
If youβre using
npm
8.3.x
or higher, you can now use:β¦since npm doesnβt support
resolutions