DEV Community

Hatem Houssein
Hatem Houssein

Posted on • Updated on

GraphQL, are we there yet?

Shopify is an E-commerce platform with cool APIs (much better than others). Their GraphQL has passed the Beta version and is now stable, and they are still maintaining REST.

Our app works with Shopify REST API and lately, we have been thinking about migrating to GraphQL. Why? GraphQL is newer, cooler and would supposedly solve performance issues due to REST API restrictions.

I started digging into their docs, which is still work in progress but good enough.

Summary of GraphQL

Per its namesake, you can imagine a graph with nodes, edges and connections. I will not get into this more but you can check this good article to know more about GraphQL.

  1. GraphQL doesn't have call limit per-say but cost rate exists. The cost normally depends on how many fields and connections cost, which is really well-explained in the article mentioned above. The cost rate is to avoid the server from crashing due to overload or attacks.

  2. Pagination exists also for GraphQL called cursor pagination, a little different from what I have experienced with REST's. Although GraphQL's pagination can be implemented in REST APIs, I haven't seen one yet. Please let me know if you know any! (Slack & Django do, thanks @rhymes !)
    -------- Update 8/11/2019 --------
    Shopify just released they're moving from page-based pagination to cursor-based pagination.

Decision-making step

From my findings and based on some others' reviews, I was skeptical about migrating from REST to GraphQL. I read some reviews saying GraphQL is powerful for some processes but is still weak for other processes.

Mixing both APIs on our app would get the best of both APIs, but adds more complexity to the codebase. I would rather avoid complexity and be limited by either APIs.

I felt Shopify's GraphQL was built upon their REST API design restricting GraphQL's advantages. My skepticism was growing and eventually, I stumbled upon this article. Based on a simple Q&A, you can see if it's worth migrating from REST to GraphQL. Of course, the decision, in the end, is up to you but it was quite affirmative to me that I was skeptical for a good reason.


Eventually, we decided to hold on the migration for a while and see what Shopify GraphQL might introduce to us in the future.
As a side-note, I believe in order to make a good GraphQL API, the API design should be thought of as a graph (with edges & nodes) to make it more efficient.

Discussion (2)

rhymes profile image
rhymes • Edited on

Hi Hatem!

Regarding GraphQL vs REST I think you realized your reasons for the migration weren't solid enough. Maybe you can call the GraphQL only for those endpoints where you are having performance issues and see if you get a speed up. I'm not familiar with Shopify's API though.

Regarding cursors based pagination: Slack's API has cursor based pagination, so has a framework like Django REST.

I think here you inverted the two technologies:

From my findings and based on some others' reviews, I was skeptical about migrating from GraphQL to REST

saulsilver profile image
Hatem Houssein Author • Edited on

Hi Rhymes!
As I’ve mentioned, mixing both APIs will only add complexity to the code base which can be confusing for the rest of the team.

Thank you very much for pointing out Slack’s and Danjgo’s, very helpful 🙌🏼

You’re right, I made a little switcheroo over there. Thank you, it’s fixed now.