Skip to content

Regression: graphql-request 7.4.0 rejects relative endpoint URLs ("/graphql") due to URL parsing in runRequest #1493

Description

@jekabs-karklins

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:

  1. Use GraphQLClient with "/graphql" directly (instead of new URL(...).toString()).
  2. Run the application (or call GraphQLClient.request directly).
  3. Observe runtime failure from URL parsing in graphql-request runRequest ("Invalid URL"), before fetch executes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions