graphql-network-inspector icon indicating copy to clipboard operation
graphql-network-inspector copied to clipboard

Support for subscriptions

Open michael-infinitusai opened this issue 4 years ago • 13 comments

Are there any plans to support inspecting GQL subscriptions in addition to queries and mutations?

michael-infinitusai avatar Sep 30 '21 14:09 michael-infinitusai

At the moment I am adding mocking support but will take a look into subscriptions afterwards. It is on the roadmap but I felt it wasn't high priority.

warrenday avatar Sep 30 '21 16:09 warrenday

+1 for mocking, I can't find anything out there to do this and it'd be a huge help for what I'm currently working on.

anthonydelage avatar Oct 15 '21 20:10 anthonydelage

Great extension! So much easier and quicker than the network tab to get an overview for GraphQL data. But really missing the subscriptions, so a big +1 on this feature request :)

robertherber avatar Feb 18 '22 14:02 robertherber

It would be great to get an idea of how everyone is working with subscriptions at the moment.

Which libraries are you using? Do you communicate over websockets or another protocol?

The end goal of this feature is to be platform/protocol agnostic. But it would be great to get an idea of where to start. As not everyone is using Apollo. :)

warrenday avatar Feb 18 '22 14:02 warrenday

I'm currently using Apollo, but moving towards urql. Not sure how you've implemented the plugin but I suppose you can derive everything by just looking at the network requests, right? Or does the Client Library matter? :)

For the subscriptions I'm currently using websockets.

robertherber avatar Feb 18 '22 15:02 robertherber

@anthonydelage I thought you'd like to know mocking is now available through a desktop version of the app. If you're on mac you can use this to proxy/intercept traffic from any site where introspection is possible.

https://graphproxy.com

It's still in early beta but let me know what you think!

warrenday avatar Mar 30 '22 16:03 warrenday

@warrenday Hmm, I think I like this better as a browser extension on Desktop tbh.. :) Although an interesting prospect would be to have it on iPad/iPhone to look at requests inside apps since DevTools aren't available.

Just tried out the desktop app - and I still don't see subscriptions there - not sure if it's supposed to work there?

robertherber avatar Mar 31 '22 11:03 robertherber

Right now the main benefits of desktop are mocking and support for other apps/browsers. But if all you need is the inspector on chrome then that's the better choice :)

Subscriptions are the next major feature to add now this is out of the way. I'll update the thread when it's ready.

They'll be included to both the desktop and chrome plugin.

warrenday avatar Mar 31 '22 15:03 warrenday

Thanks for the update!

I'm having issues mocking some (but not all) GQL requests using the trial version. Is there a way to add auth to the introspector UI so I can mock internal APIs?

Screen Shot 2022-03-31 at 13 52 07

anthonydelage avatar Mar 31 '22 17:03 anthonydelage

You could add a query string ?token=1234 to the url if auth to your server is possible that way. There's currently no way of handling auth with headers (something I hadn't considered actually). Is there a particular auth method you need?

warrenday avatar Mar 31 '22 20:03 warrenday

We use a session-based cookie for auth. Would there be a way to pass that through the Chrome extension?

anthonydelage avatar Mar 31 '22 20:03 anthonydelage

I don't think it would be possible to route through the extension. But if headers are made available when running the introspection query tokens and cookies could be specified there. So i'll look at adding this.

warrenday avatar Apr 01 '22 09:04 warrenday

That'd be super helpful, thanks 👍

anthonydelage avatar Apr 01 '22 13:04 anthonydelage

Has there been any movement on support for subscriptions?

OmarBurney avatar Jun 10 '23 18:06 OmarBurney

I would also very much like to see support for subscriptions. great library by the way.

brendanmorrell avatar Jun 27 '23 19:06 brendanmorrell

It is 100% in the roadmap. But I don't yet have a deadline.

warrenday avatar Jul 09 '23 20:07 warrenday

Closing as beta feature for subscriptions now added in 2.18.0. Let me know what you think and please raise any issues here on GitHub.

During beta the feature is disabled by default. Enable by selecting the subscription filter in the footer.

Screenshot 2023-11-15 at 09 50 36

warrenday avatar Nov 16 '23 11:11 warrenday

thanks for the quick turnaround! so, perhaps there is some setup that I am missing, but I do not seem to see any messages in the GQL network inspector despite their being there in the actual chrome network tab. screenshots attached show the subscription headers and messages. there are a lot of messages in the chrome network tab, but none in the extension unfortunately. I also notice that in the attached screenshot @warrenday posted above, the subscription seems to have had zero bytes travel over the wire, so wonder if it is not working there as well. Screenshot 2023-11-17 at 3 35 06 PM Screenshot 2023-11-17 at 3 31 37 PM

brendanmorrell avatar Nov 17 '23 22:11 brendanmorrell

love this feature but also having the issue of seeing 0 bytes over the wire, with events coming through but empty in the extension

dontsave avatar Jan 25 '24 22:01 dontsave

Could you share some details of what you see in the standard network tab Vs the GraphQL tab?

warrenday avatar Jan 26 '24 08:01 warrenday

Basically, I have maybe 4 subscriptions running, and the WS section of the actual network inspector shows many messages going back and forth. I am highlighting one in the screenshot so you can see they aren't just keep alive messages, but instead that there is actual data being sent from the client and then data being returned. Despite this, gql inspector is showing zero kb transferred/no messages. Can send any more details you need. just let me know specifically what you'd like to see.

Screenshot 2024-01-26 at 9 58 49 AM

brendanmorrell avatar Jan 26 '24 17:01 brendanmorrell

I also notice that it is picking up non-graphql subscriptions (see this image where it is grabbing a pub sub messaging subscription we use as well as webpack hot reloads (I am running our app locally in this screenshot) Screenshot 2024-01-26 at 10 06 27 AM

brendanmorrell avatar Jan 26 '24 17:01 brendanmorrell

if you need to look for yourself, the app in question is

https://app.realize.me/

you will need to create an account/sign in for the subscriptions to fire

brendanmorrell avatar Jan 26 '24 17:01 brendanmorrell

Thanks @brendanmorrell this is helpful. I'll update soon.

warrenday avatar Jan 29 '24 09:01 warrenday

@brendanmorrell I've looked at the main issue of requests not showing, and I've found the problem. Will release a fix shortly. It was purely that we were making strict assumptions on what shape the data should be in, which I've now made more flexible.

However, in the case of showing messages that are not GraphQL, this is more difficult to resolve.

For messages sent, it's not a problem, we can check the websocket payload and validate if it contains a graphql query. But for messages received, it's typically just JSON.

Even in the case of messages received over the graphql socket wss://api.realize.me/v1/graphql there are still lots of ping/pong messages, amongst other messages.

It's not possible to know which received messages are desired to be shown or not. Potentially we could add a filter input to give control over to the user.

warrenday avatar Feb 04 '24 14:02 warrenday

It does seem sensible to assume received messages will contain a "data" key, which is very common in most graphql servers. Here is the subscription view with the new updates.

Screenshot 2024-02-04 at 16 19 25

warrenday avatar Feb 04 '24 16:02 warrenday

Working great! Thanks @warrenday !

brendanmorrell avatar Feb 05 '24 21:02 brendanmorrell

Hey guys, thanks for the great work on this extension and supporting the subscriptions. Unfortunately, I'm not able to see anything in subscriptions image

Here's what I see in the network tab: image

Any thoughts?

jramiresbrito avatar May 09 '24 19:05 jramiresbrito

Hey @anthonydelage that is unusual. Could you setup a basic example, repo or live service I can clone or visit.

I'll be able to debug and deploy a patch.

warrenday avatar May 09 '24 19:05 warrenday

I think you meant to tag jramiresbrito?

anthonydelage avatar May 09 '24 19:05 anthonydelage