Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Only absolute URLs are supported when testing with jsdom. #752

Closed
MoSattler opened this issue Apr 3, 2024 · 2 comments
Closed
Labels

Comments

@MoSattler
Copy link

When running a graphql-request request in a test environment, like jsdom on nodejs, it throws an error:

TypeError: Only absolute URLs are supported

which is a problem, if I want to intercept the request with tools like MSW.

I do not have this problem with relative requests when using fetch

fetch("/some-endpoint")

those work as before and can easily be intercepted with MSW.

@MoSattler
Copy link
Author

Seems to be related to nextjs and its extended fetch function. This works:

const graphQLClient = new GraphQLClient('/api/graphql', { fetch })

@jasonkuhrt
Copy link
Member

Note that support for relative paths was dropped in the next upcoming version. If you need it, make a new issue explaining why etc. Thanks! #745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants