After upgrading from Gatsby v2.1.31 to v2.2.3 my project fails to compile all of a sudden, because the gatsby-source-graphql plugin throws the following error. I'm using this plugin to query data from the GitHub GraphQL API (v4). No source code has been changed, and I checked in the online explorer of GitHub's API: the query is still valid. I suppose the origin of this issue might lie in the new schema customization API introduced in v2.2.
After downgrading to Gatsby v2.1 everything works again (also with latest version of gatsby-source-graphql = 2.0.15).
yarn run v1.15.2
$ gatsby develop
success open and validate gatsby-configs โ 0.014 s
success load plugins โ 0.307 s
success onPreInit โ 0.678 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success initialize cache โ 0.011 s
success copy gatsby files โ 0.016 s
success onPreBootstrap โ 0.009 s
success source and transform nodes โ 2.587 s
success building schema โ 1.040 s
error gatsby-node.js returned an error
GraphQLError: Unknown type "GitHub_Blob". Did you mean "GitHub_Blame", "GitHub_Node", "GitHub_URI", "GitHub_App", or "GitHub_HTML"?
- debuggability.js:313 Promise._execute
[grubersjoe.de-current]/[bluebird]/js/release/debuggability.js:313:9
- promise.js:483 Promise._resolveFromExecutor
[grubersjoe.de-current]/[bluebird]/js/release/promise.js:483:18
- promise.js:79 new Promise
[grubersjoe.de-current]/[bluebird]/js/release/promise.js:79:10
- index.js:358 graphqlRunner
[grubersjoe.de-current]/[gatsby]/dist/bootstrap/index.js:358:14
- gatsby-node.js:16 Object.exports.createPages
/home/jogu/git/_private/grubersjoe.de-current/gatsby-node.js:16:10
- api-runner-node.js:202 runAPI
[grubersjoe.de-current]/[gatsby]/dist/utils/api-runner-node.js:202:37
- api-runner-node.js:340 resolve
[grubersjoe.de-current]/[gatsby]/dist/utils/api-runner-node.js:340:19
- debuggability.js:313 Promise._execute
[grubersjoe.de-current]/[bluebird]/js/release/debuggability.js:313:9
success createPages โ 0.086 s
success createPagesStatefully โ 0.044 s
success onPreExtractQueries โ 0.001 s
success update schema โ 0.077 s
error GraphQL Error Unknown type "GitHub_Blob". Did you mean "GitHub_Blame", "GitHub_Node", "GitHub_URI", "GitHub_App", or "GitHub_HTML"?
file: <path>/Projects.tsx
60 | name
61 | email
62 | }
63 | }
64 | }
65 | }
66 | }
67 | }
68 | }
69 | readme: object(expression: "master:README.md") {
> 70 | ... on GitHub_Blob {
| ^
71 | text
72 | }
73 | }
74 | }
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
success extract queries from components โ 0.099 s
โ (node:8313) DeprecationWarning: Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.
success run graphql queries โ 0.014 s โ 7/7 532.23 queries/second
success write out page data โ 0.013 s
success write out redirect data โ 0.002 s
success onPostBootstrap โ 0.180 s
info bootstrap finished - 6.752145856 s
With `useBuiltIns` option, required direct setting of `corejs` option
Done in 8.32s.
The source code of my website is public, so you can simply clone the repo out and run below command: https://github.com/grubersjoe/grubersjoe.de
A GitHub access token is required with the following permissions to authenticate:
GITHUB_TOKEN=<token> yarn dev
An example query, which fails:
{
github {
viewer {
repositories(first: 10, privacy: PUBLIC) {
edges {
node {
name
readme: object(expression: "master:README.md") {
... on GitHub_Blob {
text
}
}
}
}
}
}
}
}
The project should compile without complaining GraphQL Error Unknown type "GitHub_Blob". Blob is a valid object: https://developer.github.com/v4/object/blob/. All objects processed by the source plugin are prefixed with GitHub_, as configured in gatsby-config.js (typeName):
plugins: [
{
resolve: 'gatsby-source-graphql',
options: {
fieldName: 'github',
typeName: 'GitHub',
createLink: () => createHttpLink({
uri: 'https://api.github.com/graphql',
headers: {
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
fetch,
}),
},
},
// ...
The plugin is unable to correctly resolve the GraphQL schema, thus breaking the build. See above output.
System:
OS: Linux 5.0 Arch Linux undefined
CPU: (4) x64 Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 11.12.0 - /usr/bin/node
Yarn: 1.15.2 - /usr/bin/yarn
npm: 6.9.0 - /usr/bin/npm
Languages:
Python: 3.7.2 - /usr/bin/python
Browsers:
Firefox: 66.0
npmPackages:
gatsby: ^2.0.52 => 2.2.3
gatsby-image: ^2.0.20 => 2.0.34
gatsby-plugin-feed: ^2.0.11 => 2.0.15
gatsby-plugin-google-analytics: ^2.0.9 => 2.0.17
gatsby-plugin-manifest: ^2.0.13 => 2.0.24
gatsby-plugin-offline: ^2.0.15 => 2.0.25
gatsby-plugin-react-helmet: ^3.0.2 => 3.0.10
gatsby-plugin-sharp: ^2.0.13 => 2.0.30
gatsby-plugin-sitemap: ^2.0.2 => 2.0.10
gatsby-plugin-styled-components: ^3.0.2 => 3.0.7
gatsby-plugin-typescript: ^2.0.1 => 2.0.11
gatsby-remark-copy-linked-files: ^2.0.8 => 2.0.11
gatsby-remark-external-links: ^0.0.4 => 0.0.4
gatsby-remark-images: ^3.0.1 => 3.0.10
gatsby-remark-prismjs: ^3.2.0 => 3.2.6
gatsby-remark-responsive-iframe: ^2.0.8 => 2.1.1
gatsby-remark-smartypants: ^2.0.7 => 2.0.9
gatsby-source-filesystem: ^2.0.8 => 2.0.27
gatsby-source-graphql: ^2.0.6 => 2.0.15
gatsby-transformer-remark: ^2.2.0 => 2.3.7
gatsby-transformer-sharp: ^2.1.8 => 2.1.17
Thanks for the detailed report! Could you try if #12720 fixes the issue for you? Thanks a lot!
Sorry about that, it should be fixed in #12721.
I get a different error than you--could you maybe push a branch where we can reproduce your exact issue?
I did yarn add [email protected] and then GITHUB_TOKEN=hunter2 yarn build and I receive:
Error: Schema must contain unique named types but contains multiple types named "Query".
Of course--can validate that it works in gatsby@~2.1.0--so this definitely seems like a regression.
@DSchau The error you are seeing was fixed in [email protected] with #12668
@stefanprobst ๐ yup yup.
With [email protected] I get:
GraphQLError: Unknown type "GitHub_Blob". Did you mean "GitHub_Blame", "GitHub_Node", "GitHub_URI", "GitHub_App", or "GitHub_HTML"?
with [email protected] I get:
Error: GitHub.relay cannot convert to OutputType the following string: 'Query'
I'm seeing the same error. So I fear this is still broken :sweat_smile:.
yes, so sorry, this is indeed not yet fully fixed (but almost :wink:). Btw GitHub.relay is the weirdest field I have ever seen, even the field description says it's a hack.
Published in [email protected]
Have run into the same issue the last few days as well - @2.2.7 just fixed it
Thank you for the quick fix. It works now :).
Most helpful comment
Published in [email protected]