question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load a remote Contentful schema.

See original GitHub issue

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.

  1. My GraphQL operations:

Too many to list, but could be provided if necessary.

  1. 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:

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:open
  • Created a year ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

1reaction
alexbjorligcommented, Jun 21, 2022

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 rocking

1reaction
alexbjorligcommented, Jun 18, 2022

I’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:

❯ npm ls undici
<root>
└─┬ @graphql-codegen/cli@2.6.2
  └─┬ @graphql-tools/github-loader@7.2.5
    └─┬ cross-undici-fetch@0.1.33
      └── undici@5.5.1

With the following in overrides:

    "overrides": {
        "@graphql-codegen/cli@2.6.2": {
            "@graphql-tools/github-loader@7.2.5": {
                "cross-undici-fetch@0.1.33": {
                    "undici": "5.0.0"
                }
            }
        }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

fetching a remote schema throws 400 errors #573 - GitHub
Description I am trying to get a remote schema using command below. ... I use another cli utility from “get-graphql-schema” and this works...
Read more >
GraphQL schema stitching to combine APIs: Part 2 - Contentful
The first step is to link up to a remote schema. To create such a schema, we need to create an HTTP link...
Read more >
Combining Contentful GraphQL and Postgres via Hasura
Head into the remote schemas section of Hasura to add Contentful. Using the API keys from Contentful, set the URL as https://graphql.contentful.
Read more >
Content Management API | Contentful
The Upload API enables the uploading of files to remote storage. To complete an upload, the uploaded file must be associated with an...
Read more >
Webhooks - Contentful
Common use cases for content event webhooks include: running a test suite on a CI service ... Click Add webhook, configure the remote...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found