jasonkuhrt / graphql-request

Minimal GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

MoSattler opened this issue · comments

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.

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

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

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