Skip to content

GraphiQL uses currently unsupported graphql-transport-ws protocol for subscriptions #1756

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

Closed
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 do not work because of protocol mismatch.

GraphiQL uses graphql-ws client (graphql-transport-ws protocol) for subscriptions.

Currently graphql-kotlin provides default server implementation for older apollo client (subscriptions-transport-ws protocol).

To Reproduce
Open default latest version Spring Server GraphiQL UI

Expected behavior
If user is using deprecated apollo protocol, initiate the graphiql client with compatible subscription client.

Partial solution

  1. In graphql-graphiql.html add dependency for deprecated protocol client:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/browser/client.js"
        integrity="sha384-I1OLTTX4GzmfsCxgHUuqdP/zG05aDwlVdlx8Q3rDQNInfapBSnnJDgLuWZkj2tEH"
        crossorigin="anonymous"></script>
  1. Then initiate fetchers using legacyWsClient option:
var fetcher = GraphiQL.createFetcher({
  url: serverUrl,
  legacyWsClient: new SubscriptionsTransportWs.SubscriptionClient(subscriptionUrl)
});
@jaaqo jaaqo added the type: bug Something isn't working label Apr 18, 2023
dariuszkuc pushed a commit that referenced this issue Jun 26, 2023
…LSubscriptionsRoute (#1804)

### 📝 Description

This is a small fix to set `graphql-transport-ws` subprotocol as
(sensible) default for Ktor server `graphQLSubscriptionsRoute`.

Without that line, users may encounter issues when sending requests
using popular GQL clients like Apollo or even bundled GraphiQL UI,
because of they are sending
`Sec-Websocket-Protocol=graphql-transport-ws` header and that is being
rejected by Ktor.

Users may still override this value, if needed

### 🔗 Related Issues

#1756
@dariuszkuc
Copy link
Collaborator

Added support for graphql-transport-ws to Spring in #1810. Legacy subscription-transport-ws protocol will be dropped in next major (i.e. v8).

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