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

fix/feat(serve): WebSockets for GW/Client comm #7766

Merged
merged 8 commits into from
Oct 22, 2024
Merged

Conversation

ardatan
Copy link
Owner

@ardatan ardatan commented Oct 14, 2024

Expose WebSockets server for the gateway and the client communication

Previously it wasn't possible to communicate with the gateway via WebSockets, now this implements it, updates the tests to make sure the gateway is accessible through WebSockets

  • WebSocket connection for node:http server in serve-cli
  • onRequest is not invoked when using WebSockets with uWS, therefore we cannot assign a schema to a request in useSchema Yoga plugin - do something else
    (Now setting the schema in onSubscribe hook of graphql-ws)
  • Serve config option to enable/disable WebSocket connections
  • Forward connection params upstream
    • See E2E tests
  • Documentation
    • Will be done after

Closes #7208

@ardatan ardatan requested a review from enisdenjo October 14, 2024 10:11
Copy link
Contributor

github-actions bot commented Oct 14, 2024

The build artifacts of mesh-serve as a single executable for macOS-ARM64 are available at:
Download

Copy link
Contributor

github-actions bot commented Oct 14, 2024

The build artifacts of hive-gateway as a single executable for Linux-X64 are available at:
Download

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

Copy link
Contributor

github-actions bot commented Oct 14, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-hive/gateway 1.3.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/hmac-upstream-signature 1.2.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-jwt-auth 1.2.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 1.3.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-operation-headers 1.2.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 1.2.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/serve-cli 1.3.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/serve-runtime 1.2.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http-callback 0.5.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6 npm ↗︎ unpkg ↗︎

Copy link
Contributor

github-actions bot commented Oct 14, 2024

💻 Website Preview

The latest changes are available as preview in: https://51789e9a.graphql-mesh.pages.dev

Copy link
Contributor

github-actions bot commented Oct 14, 2024

The build artifacts of mesh-serve as a single executable for macOS-X64 are available at:
Download

Copy link
Contributor

github-actions bot commented Oct 14, 2024

The build artifacts of hive-gateway as a single executable for Windows-X64 are available at:
Download

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Published mesh-serve images for this PR are available at:

ghcr.io/ardatan/mesh-serve:1.3.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Published hive-gateway images for this PR are available at:

ghcr.io/ardatan/hive-gateway:1.3.0-alpha-20241017125351-19cd1c2d9a00f9217e1b38b0aa023f2e54a731d6

Copy link
Collaborator

@enisdenjo enisdenjo left a comment

Choose a reason for hiding this comment

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

Are these #7208 fully covered too?

Comment on lines 146 to 152
const { WebSocketServer } = await import('ws');
const wsServer = new WebSocketServer({
path: gwRuntime.graphqlEndpoint,
server,
});
const graphqlWSOptions = getGraphQLWSOptions(gwRuntime);
const { useServer } = await import('graphql-ws/lib/use/ws');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why dynamic imports? Dynamic imports make it hard for bundlers.

@ardatan ardatan requested a review from enisdenjo October 17, 2024 12:50
@ardatan ardatan merged commit cc53c6c into master Oct 22, 2024
8 of 11 checks passed
@ardatan ardatan deleted the ws-support-gww branch October 22, 2024 09:44
ardatan added a commit that referenced this pull request Nov 20, 2024
* fix/feat(serve): WebSockets for GW/Client comm

* chore(dependencies): updated changesets for modified dependencies

* Fix unit tests

* Fix e2e

* Disable v18 for WS

* Avoid dynamic imports

* Add an option to enable/disable WebSockets

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1] WebSocket server for the serve-cli
2 participants