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

Add support for websocket endpoint with graphql-ws #1326

Merged
merged 1 commit into from
Apr 25, 2022

Conversation

lethot
Copy link
Contributor

@lethot lethot commented May 1, 2021

Changes proposed in this pull request:

  • add graphql-ws to support subscription and full graphql over websockets

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 1, 2021

CLA Signed

The committers are authorized under a signed CLA.

@ntziolis
Copy link

ntziolis commented May 8, 2021

When can we expect this to be merged in?

@ardatan
Copy link
Member

ardatan commented May 12, 2021

@lethot We can have more features by adding GraphQL Tools Url Loader as in this PR. What do you think @acao ?
https://github.com/contrawork/graphql-helix/pull/33/files#diff-d04dada0c5eb3a6ab96feb1d2ce9abc653a7b5d859693aea37621e43a6b4b9feR3

@maxpain
Copy link

maxpain commented Jun 1, 2021

Any updates?

Comment on lines +27 to +52
const client = createClient({
url: this.state.endpoint,
retryAttempts:0
});
const unsubscribe = client.subscribe(
{
query: `{
__schema {
queryType {
kind
}
}
}`,
},
{
next: () => {
this.setState({ valid: true })
unsubscribe()
},
error: () => {
this.setState({ valid: false });
unsubscribe()
},
complete: () => {},
},
);
Copy link
Member

@enisdenjo enisdenjo Jun 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simpler way to achieve the same check would be by disabling lazy mode (connect on instantiation) and check if the client connected.

Suggested change
const client = createClient({
url: this.state.endpoint,
retryAttempts:0
});
const unsubscribe = client.subscribe(
{
query: `{
__schema {
queryType {
kind
}
}
}`,
},
{
next: () => {
this.setState({ valid: true })
unsubscribe()
},
error: () => {
this.setState({ valid: false });
unsubscribe()
},
complete: () => {},
},
);
const client = createClient({
url: this.state.endpoint,
retryAttempts: 0,
lazy: false,
on: {
closed: () => this.setState({ valid: false }),
connected: (socket) => {
this.setState({ valid: true });
client.dispose(); // dispose after validation
},
},
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, I forgot to commit this suggestion. @lethot or @enisdenjo can you follow on a PR with this correction?

@maxpain
Copy link

maxpain commented Jun 25, 2021

Any news?

@elderapo
Copy link

What's blocking from getting this merged? Any way to help?

Copy link
Member

@acao acao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@acao acao merged commit 3a09b2e into graphql:main Apr 25, 2022
@intellix
Copy link

intellix commented Sep 20, 2022

This says that it was merged on 25th April but I don't see any newly published graphql-playground-html packages since 1yr ago: https://www.npmjs.com/package/graphql-playground-html (1.6.30 @ 11/4/2021 6pm).

Is this merged item available anywhere?

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

Successfully merging this pull request may close these issues.

9 participants