Skip to content

Conversation

@cwangsmv
Copy link
Contributor

Changes:

  • Using websocket connection for Graphql subscritpion operations
graphql-subscription.mp4

Closes #6055

@cwangsmv cwangsmv force-pushed the feat/graph-subscription-support branch from 70cb07c to bde59c0 Compare September 23, 2024 09:03
@cwangsmv cwangsmv marked this pull request as draft September 23, 2024 10:09
@cwangsmv cwangsmv force-pushed the feat/graph-subscription-support branch from 72ae829 to 742ecec Compare September 23, 2024 15:02
@cwangsmv cwangsmv marked this pull request as ready for review September 24, 2024 02:06
Copy link
Contributor

@jackkav jackkav left a comment

Choose a reason for hiding this comment

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

Curious the see how persistent the connection is. What if you navigate to another workspace and back? Or open a second instance of insomnia.

const { url, method } = activeRequest;
const isEventStreamOpen = useReadyState({ requestId: activeRequest._id, protocol: 'curl' });
const isCancellable = currentInterval || currentTimeout || isEventStreamOpen;
const isGraphQLSubscriptionOpen = useReadyState({ requestId: activeRequest._id, protocol: 'webSocket' });
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit tempted to try to merge the action-bar.tsx into this one as its mostly copypasta and this is the only important line in that component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, so both normal request and websocket request could use request-url-bar.tsx

Copy link
Contributor

Choose a reason for hiding this comment

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

Can scope it out of this PR though.

Copy link
Contributor

@jackkav jackkav left a comment

Choose a reason for hiding this comment

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

really elegant implementation

@cwangsmv
Copy link
Contributor Author

Curious the see how persistent the connection is. What if you navigate to another workspace and back? Or open a second instance of insomnia.

It's a reuse of the current websocket connection logic so it will have the same behavior. Current when nav to another workspace and back, the connection will be closed

Comment on lines 83 to 84
"graphql-ws": "^5.16.0",
"graphql": "^16.8.1"
Copy link
Contributor

@jackkav jackkav Sep 25, 2024

Choose a reason for hiding this comment

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

running npm i -w insomnia -S graphql-ws will fix this ordering issue

jackkav
jackkav previously approved these changes Sep 25, 2024
@cwangsmv cwangsmv force-pushed the feat/graph-subscription-support branch from 0335289 to 5e194b2 Compare September 25, 2024 16:34
Copy link
Contributor

@notjaywu notjaywu left a comment

Choose a reason for hiding this comment

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

lgtm

@cwangsmv cwangsmv merged commit 6f61018 into develop Sep 26, 2024
@cwangsmv cwangsmv deleted the feat/graph-subscription-support branch September 26, 2024 07:27
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.

Support GraphQL subscriptions via WebSocket

4 participants