`TypeError: Only absolute URLs are supported` when testing with jsdom.
MoSattler opened this issue · comments
Mo Sattler commented
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.
Mo Sattler commented
Seems to be related to nextjs and its extended fetch function. This works:
const graphQLClient = new GraphQLClient('/api/graphql', { fetch })
Jason Kuhrt commented
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