Skip to main content

GraphQL

Why we chose GraphQL​

Centra exclusively offers GraphQL APIs. This allows for selective operations, fetching only what's necessary to accomplish your goals.

In the ecommerce space, data models can grow large. GraphQL is a good fit to reduce the impact of those model sizes, leading to a better shopping experience.

GraphQL vs REST​

Coming from REST APIs, it's useful to keep a few things in mind.

  • There is no default response data model. You must be explicit in what to be returned. Again, specify only what you need.
  • While REST tends to use a rich suite of HTTP response codes, GraphQL may handle errors differently. A 200 OK in GraphQL does not necessarily represent a flawless success. Since a single request may conduct multiple operations, the status of a single request is layered. As an example, the HTTP layer may succeed while operations fail. You can read more here.
  • While REST may use the HTTP method to suggest the type of operation, virtually all GraphQL requests are made using POST.
  • While REST separates functions by path, GraphQL does so by operations. As a result, all GraphQL requests are sent to the same URL.