Home Extract GraphQL calls from a browser for debug in Postman
Post
Cancel

Extract GraphQL calls from a browser for debug in Postman

TLDR: You can right-click->copy as curl right from devtools, and paste into postman for on the spot debugging!

For this all you need is a browser with devtools, Postman, and a GraphQL call.

So,

you have a moody or misbehaving GraphQL call in one of your web apps, and you wish you could just change one thing about the call, on the fly, just to see what happens. Or maybe the call really does need to be debugged and reworked in a major way but you want to test it first. Or maybe you just want a faster way to get the call in front of you.

So let’s use this little tool to emulate an app making a GraphQL call: https://lucasconstantino.github.io/graphiql-online/

Here’s my query:

1
2
3
4
5
6
7
8
9
10
11
12
query($filter: CountryFilterInput) {
  countries(filter: $filter) {
    name
    code
    phone
    continent {
      code
      name
    }
    capital
  }
}

Variables:

1
2
3
{
  "filter": {"code": {"in": ["CA","US","GB"]}}
}

Copy the query from a browser

Open your browsers dev-tools, usually you can right click anywhere on the page and select Inspect. Click over to the Network tab of the tools, Filter if you like, for Fetch/XHR requests, Then run the query to see the call as shown in the screenshot below.

01

Copy the call with a few clicks:

02

Paste into Postman via Import

Over in Postman, find and click your Import button:

03

Paste your call via the Raw text tab:

04

05

Confirm the import - the defaults are fine:

06

Click Send

Magic! Now we can play around with the variables and other parameters of the query after only a dozen clicks! 07

That’s all for this one, I hope you found this interesting!

This post is licensed under CC BY 4.0 by the author.

Migrate and Sync Craft CMS data in minutes with n8n

Persist n8n community nodes on docker through updates (UPDATED 04-30)

Comments powered by Disqus.