DEV Community

Cover image for How to Test GraphQL API?

How to Test GraphQL API?

Jatin Sharma on December 08, 2022

You've just created a GraphQL API and are ready to test it. But where do you start? How do you know if it's working correctly? Testing your API is...
Collapse
 
liyasthomas profile image
Liyas Thomas

Since you mentioned Postman, and few other alternatives for testing APIs, I'd like to suggest Hoppscotch - API request builder for web.

Hoppscotch is open source { free } alternative to Postman.

hoppscotch.io

GitHub logo hoppscotch / hoppscotch

๐Ÿ‘ฝ Open source API development ecosystem - https://hoppscotch.io

Collapse
 
j471n profile image
Jatin Sharma

Yes, that's actually really good. I used this a few times.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€

A couple of things I didnโ€™t know that Iโ€™ve picked up over the last year.

  • In some ways OpenAPI is a perfectly fine REST alternative
  • GraphQL is for larger complex projects with many moving parts, donโ€™t add it to just any project
  • It works under the hood like a regular API and itโ€™s mainly just an abstraction at the end of the day
  • JavaScript fetch is all you need to make a query, no libraries required from a client
Collapse
 
fjones profile image
FJones • Edited

I would compare GraphQL more to RPC than REST, but it has some elements of both (e.g. considering graph nodes as resources).
Other than that, though, yeah, that's pretty much the basics.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€

Iโ€™ve no comment about the design of the API as I know only REST and itโ€™s constraints (for shame!) but I shall have to find the use cases for RPC. However my comment about OpenAPI in particular relates towards typed schema and standards (got to love standards, like the Amazon open api ecosystem of code generation tools, Iโ€™ve recently posted a few times about it), thanks for sharing your views and il go read now

Collapse
 
mariamarsh profile image
Maria ๐Ÿฆ Marshmallow

It is really impossible to work with GraphQL on mobile phones without such tools, has anyone tried doing this from a browser? Making requests or exploring docs is very inconvenient, and even landscape mode doesnโ€™t help.

Collapse
 
j471n profile image
Jatin Sharma • Edited

Well as far as I have experienced the making request in browser sucks. It's because you have to write code in browser and sometimes you have to scroll. These things makes its harder to work on mobile browser. That's why Mobile app are the way to go. As far as the docs are concerned, I haven't had any problem with it so far on Mobile devices.

Collapse
 
tristankalos profile image
Tristan Kalos

Postman recently has updated their support for GraphQL in their Client. Might be worth a check!

Collapse
 
amyswen451 profile image
Amanda Swensen

Have you had real experience with GraphQL?

Collapse
 
j471n profile image
Jatin Sharma

Currently I am working on a side project with GraphQL so yeh I have a little bit of experience with GraphQL.

Collapse
 
amyswen451 profile image
Amanda Swensen

It would be interesting to see a post about your project, because it seems that you are very knowledgeable in GraphQL

Thread Thread
 
j471n profile image
Jatin Sharma

I am working on a couple of projects right now. And yeah, sure when I'll finish my project I'll release a detailed post about How I made that same as How I Made My Portfolio with Next.js

Thread Thread
 
amyswen451 profile image
Amanda Swensen

Sounds good

Collapse
 
alessioferrine profile image
alessioferrine

Very helpful article, thanks for your efforts

Collapse
 
j471n profile image
Jatin Sharma

It's always a pleasure :)

Collapse
 
_min_a4bc8b07de6177b694 profile image
๋ฏผ๊ฒฝ Min

Nice post! Quickly tried sending some requests to GitHub GraphQL API, runs smoothly and is actually quite easy to use
Image description

Collapse
 
j471n profile image
Jatin Sharma

Yes exactly, it's very simple to use.

Collapse
 
frederickprice profile image
Frederick Price

By the way, I noticed that there are more and more mobile solutions for developers. Apparently people like to work directly from their smartphones.

Collapse
 
j471n profile image
Jatin Sharma

Yeh exactly, the thing is you don't carry you laptop all the time (atleast I Don't carry) so when you need something done you think "I wish I could do this on my mobile phone"

Well that's my thoughts. I do many things from mobile such as writting this comment ๐Ÿ˜„

Collapse
 
ayuryshev profile image
Alex Yu

I'm quite surprised why nobody mention jupyter-notebook.
It is much more flexible than postman, it's great as documentation tool and it could be used for automated tests too.

Collapse
 
j471n profile image
Jatin Sharma

I don't know...personally I don't like Jupyter-notebook. It could be very useful for many developer but I am not very attached to it. Well this is just applicable to me I guess.

Collapse
 
phophogr profile image
Phoebe Green

Great post! The app you mentioned, API Tester, seems to be very useful for GraphQL๐Ÿ‘๐Ÿป

Collapse
 
j471n profile image
Jatin Sharma

Yes, It's very useful and you can test REST API as well.

Collapse
 
bangyslower profile image
Bangy Slower

Thanks for sharing. GraphQL is new for me, you brings the overall view about its ecosystem

Collapse
 
j471n profile image
Jatin Sharma

Thanks mate :)

Collapse
 
igibsonconor profile image
Conor Gibson

It would be great if you write an article about testing GraphQL using the desktop tool with useful example

Collapse
 
j471n profile image
Jatin Sharma

Added in todo list. โœจ

Collapse
 
mikedevkelly profile image
mikedevkelly

Great post! If you could do one on WebSocket testing too, would be nice

Collapse
 
j471n profile image
Jatin Sharma

Never say never โœจ

Collapse
 
merc_opolo profile image
Merc Opolo

It was a pleasure to read your post. Be cool if you compare GraphQL with other API Query Languages

Collapse
 
j471n profile image
Jatin Sharma

That's actually I nice idea ๐Ÿ’ก thanks for this. I might make post on this.

Collapse
 
zoya_tolmanova_e9195b0223 profile image
Zoya Tolmanova

๐Ÿ‘Œ๐Ÿป