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

GraphiQL subscriptions URL is forced to relative URL #1754

Closed
jaaqo opened this issue Apr 18, 2023 · 1 comment
Closed

GraphiQL subscriptions URL is forced to relative URL #1754

jaaqo opened this issue Apr 18, 2023 · 1 comment
Labels
type: bug Something isn't working

Comments

@jaaqo
Copy link
Contributor

jaaqo commented Apr 18, 2023

Library Version
7.0.0-alpha.5

Describe the bug
GraphiQL subscriptions URL is relative, when absolute is expected.

Trace:
https://github.com/graphql/graphiql/blob/main/packages/graphiql-toolkit/src/create-fetcher/createFetcher.ts#L56
https://github.com/graphql/graphiql/blob/main/packages/graphiql-toolkit/src/create-fetcher/lib.ts#L82
https://github.com/enisdenjo/graphql-ws/blob/master/src/client.ts#L519
whatwg/websockets#20

To Reproduce
https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-server/src/main/resources/graphql-graphiql.html#L48

Expected behavior
Use current window.location.href to construct absolute url by default.

Working solution

const subscriptionUrl = new URL("/${subscriptionsEndpoint}", location.href);
subscriptionUrl.protocol = location.protocol === "https:" ? "wss" : "ws";
@jaaqo jaaqo added the type: bug Something isn't working label Apr 18, 2023
@samuelAndalon
Copy link
Contributor

Hello 👋🏼, feel free to open a PR, should be a pretty straightforward change.

jaaqo added a commit to jaaqo/graphql-kotlin that referenced this issue Apr 18, 2023
Resolve absolute url for graphiql subscriptions using
window.location.href.

Fixes issue ExpediaGroup#1754.
samuelAndalon pushed a commit that referenced this issue Apr 18, 2023
Resolve absolute url for graphiql subscriptions using
window.location.href.

Fixes issue #1754.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

2 participants