dotansimha / dotansimha/graphql-code-generator
Unable to load a remote Contentful schema.
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe 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).
1. My GraphQL schema:
Too large, but could be provided if necessary.
2. My GraphQL operations:
Too many to list, but could be provided if necessary.
3. My `codegen.yml` config file:
```json
{
"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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.