Skip to content

Commit c35884d

Browse files
committed
aa
1 parent 596f47a commit c35884d

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

.changeset/nasty-beers-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphiql/toolkit': minor
3+
---
4+
5+
support graphql SSE for `options.subscriptionUrl`

packages/graphiql-toolkit/src/create-fetcher/createFetcher.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ export function createGraphiQLFetcher(options: CreateFetcherOptions): Fetcher {
4343
: false;
4444

4545
if (isSubscription) {
46-
if (!options.subscriptionUrl.startsWith('ws')) {
47-
const sseFetcher = await createSseFetcher({ url: options.sseUrl });
46+
if (
47+
options.subscriptionUrl &&
48+
!options.subscriptionUrl.startsWith('ws')
49+
) {
50+
const sseFetcher = await createSseFetcher({
51+
url: options.subscriptionUrl,
52+
});
4853
return sseFetcher(graphQLParams);
4954
}
5055

packages/graphiql-toolkit/src/create-fetcher/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ export interface CreateFetcherOptions {
8181
*/
8282
url: string;
8383
/**
84-
* url for websocket subscription requests
84+
* url for websocket subscription requests or SSE
8585
*/
8686
subscriptionUrl?: string;
87-
/**
88-
* url for graphql-sse
89-
*/
90-
sseUrl?: string;
9187
/**
9288
* `wsClient` implementation that matches `ws-graphql` signature,
9389
* whether via `createClient()` itself or another client.

packages/graphiql/cypress/e2e/ws-sse.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('IncrementalDelivery support via fetcher', () => {
1919

2020
it('should work with sse', () => {
2121
cy.visit(
22-
`/?sseUrl=http://localhost:8080/graphql/stream&query=${testSubscription}`,
22+
`/?subscriptionUrl=http://localhost:8080/graphql/stream&query=${testSubscription}`,
2323
);
2424
cy.clickExecuteQuery();
2525
assertResponse();

packages/graphiql/resources/renderExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ root.render(
7777
React.createElement(GraphiQL, {
7878
fetcher: GraphiQL.createFetcher({
7979
url: getSchemaUrl(),
80-
subscriptionUrl: 'ws://localhost:8081/subscriptions',
81-
sseUrl: parameters.sseUrl,
80+
subscriptionUrl:
81+
parameters.subscriptionUrl || 'ws://localhost:8081/subscriptions',
8282
}),
8383
query: parameters.query,
8484
variables: parameters.variables,

0 commit comments

Comments
 (0)