Description
There is a regression in graphql-request 7.4.0 when a relative endpoint is used (for example "/graphql").
In runRequest.ts, the URL is now always parsed with new URL(params.url), and middleware output is also reparsed with new URL(urlNew). This requires an absolute URL and throws for relative paths.
GraphQLClient still accepts endpoint as a plain string and does not validate/normalize it before request execution.
This is a behavior change vs previous versions where relative URLs could work in browser contexts (fetch would resolve relative paths against the current origin).
Current behavior:
- Passing "/graphql" to GraphQLClient leads to a runtime URL parsing error ("Invalid URL") before fetch is called.
Expected behavior:
- Relative URLs should continue to be supported (resolved against current origin in browser), or the library should clearly validate and document the new absolute-URL-only requirement.
Repository context:
- This repo depends on graphql-request 7.4.0 in frontend and e2e.
- Existing call sites here already work around the issue by constructing absolute URLs first.
Reproduction Steps/Repo Link
Steps:
- Use GraphQLClient with "/graphql" directly (instead of new URL(...).toString()).
- Run the application (or call GraphQLClient.request directly).
- Observe runtime failure from URL parsing in graphql-request runRequest ("Invalid URL"), before fetch executes.
Description
There is a regression in graphql-request 7.4.0 when a relative endpoint is used (for example "/graphql").
In runRequest.ts, the URL is now always parsed with new URL(params.url), and middleware output is also reparsed with new URL(urlNew). This requires an absolute URL and throws for relative paths.
GraphQLClient still accepts endpoint as a plain string and does not validate/normalize it before request execution.
This is a behavior change vs previous versions where relative URLs could work in browser contexts (fetch would resolve relative paths against the current origin).
Current behavior:
Expected behavior:
Repository context:
Reproduction Steps/Repo Link
Steps: