Unable to load a remote Contentful schema.
See original GitHub issueDescribe the bug
Seemingly without an update to graphql-codegen or any of the associated packages / plugins I am using, the process can no longer load the schema. I am not aware of any changes to Contentful in terms of the service so its a bit of a mystery. I made no updates to versions of graphql-codegen (other than trying to update to latest to see if that resolved the issue) so I’m not sure why it has just suddenly stopped working. I have no changes in my source code since the last successful run so I’m out of ideas…
Really found this to be a useful tool in my workflow so it would be a shame to do without it.
To Reproduce
npm run graphql-codegen (config provided bellow).
- My GraphQL schema:
Too large, but could be provided if necessary.
- My GraphQL operations:
Too many to list, but could be provided if necessary.
- My
codegen.yml
config file:
{
"schema": [{
"https://graphql.contentful.com/content/v1/spaces/***/environments/master": {
"headers": {
"Authorization": "Bearer ***"
}
}
}],
"documents": [
"**/*.{graphql,gql,js,ts,vue}"
],
"generates": {
"./graphql/types.ts": {
"plugins": [
"typescript",
"typescript-resolvers",
"typescript-operations"
]
},
"./graphql/operations.ts": {
"plugins": [
"typescript-resolvers",
"typescript-document-nodes"
]
}
}
}
Expected behavior
Codegen process should run as it has previously.
Environment:
- OS: MacOS Monterey
- “@graphql-codegen/cli”: “2.6.2”,
- “@graphql-codegen/typescript”: “2.4.7”,
- “@graphql-codegen/typescript-document-nodes”: “2.2.7”,
- “@graphql-codegen/typescript-operations”: “2.3.4”,
- “@graphql-codegen/typescript-resolvers”: “2.5.4”,
- NodeJS: 16.14.2
Additional context
Terminal output error:
Failed to load schema for "./graphql/operations.ts"
Failed to load schema from https://graphql.contentful.com/content/v1/spaces/***/environments/master:
this.splice is not a function
TypeError: this.splice is not a function
at HeadersList.append (/Users/***/node_modules/cross-undici-fetch/dist/patch-headers-list.js:44:16)
at Headers.append (/Users/***/node_modules/undici/lib/fetch/headers.js:215:31)
at fill (/Users/***/node_modules/undici/lib/fetch/headers.js:72:15)
at new Headers (/Users/***/node_modules/undici/lib/fetch/headers.js:168:5)
at new Request (/Users/***/node_modules/cross-undici-fetch/dist/create-node-ponyfill.js:84:29)
at Object.fetch (/Users/***/node_modules/cross-undici-fetch/dist/create-node-ponyfill.js:116:24)
at defaultAsyncFetch (/Users/***/node_modules/@graphql-tools/url-loader/index.js:41:29)
at /Users/***/node_modules/@graphql-tools/url-loader/index.js:492:36
at new ValueOrPromise (/Users/***/node_modules/value-or-promise/build/main/ValueOrPromise.js:14:21)
at executor (/Users/***/node_modules/@graphql-tools/url-loader/index.js:460:20)
GraphQL Code Generator supports:
- ES Modules and CommonJS exports (export as default or named export "schema")
- Introspection JSON File
- URL of GraphQL endpoint
- Multiple files with type definitions (glob expression)
- String in config file
Try to use one of above options and run codegen again.
NOTE: triple stars represent redacted paths / credentials.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:6
I managed to hack around by simply adding
"undici": "5.0.0"
as a dev-dependency… It does not look nice, but keeps the boat rockingI’m also on a turborepo npm v8.5.0, but the solutions described here don’t help. I still get the
this.splice is not a function
error 🤔When I run
npm ls undici
I get:With the following in overrides: