GraphQL API
Author:
Fluent Commerce
Changed on:
5 July 2024
Overview
The Fluent GraphQL API provides powerful access to data, integration, and orchestration-driven business logic. It provides an opportunity to streamline and optimize requests to the Fluent Order Management platform in a way that is more flexible than the REST-based API.
Key points
- Schema Documentation
- Benefits of GraphQL
- Why Did We Choose GraphQL?
- Differences Between REST and GraphQL-based APIs
Schema
The latest Schema Documentation can be found in the documentation or ask your Fluent Consultant for more details
Benefits of GraphQL
Efficiency
GraphQL allows the end-user to send multiple queries or mutations within a single HTTP request. This reduces network latency, chattiness and allows developers to retrieve/write the specific data they need in one go, if it is the most optimal and logical thing to do.
Flexibility
As the name suggests, retrieving data from the server can be done in a Query Language-like approach, where the end-user defines which fields and objects they would like to receive, rather than being forced to retrieve predefined Data Transfer Objects as is typical with REST-based APIs.
Unification
As well as efficiency benefits, the ability to query multiple data objects, and declare the fields to be returned for each data object, allows developers to work with unified data objects on the client side.
Introspection & Validation
GraphQL APIs provide a schema that allows clients to introspect and validate their queries, mutations, and overall interaction with the API on the client side, prior to executing or sending the HTTP request.
Why Did We Choose GraphQL
The Fluent Platform is a SaaS (Software as a Service) and a PaaS (Platform as a Service). Our platform is Cloud Native and integration with the Fluent eco-system is HTTP based. To this end, we identified the challenges of maintaining and updating our REST APIs while remaining backward compatible, yet providing optimized, efficient, and capable functionality and integration points for our clients. Once we heard about GraphQL, we saw its potential, and while still not as well known as REST, we knew our clients and partners would love it!
We've got a lot more planned for Fluent Order Management's capability. GraphQL, together with various other technologies and frameworks, will enable us to take our platform to the next level and deliver an industry-leading solution to our clients.
Differences Between REST and GraphQL-based APIs
For developers familiar with REST-based APIs, we highly recommend spending time learning GraphQL and understanding the key differences. This will result in a better writing approach, in line with recommended practices, for direct API request's and within the Rubix Plugin Rule's.
Some of the fundamental differences between the Fluent REST API and the Fluent GraphQL API include:
- GraphQL is always a POST HTTP Method.
- GraphQL returns 200 OK HTTP Status, even if errors occur. Errors will be in the Response body.
- GraphQL queries that do not find any result respond as 200 OK, and a data object with a null or empty entity field.
- GraphQL schema provides strongly typed validation and includes documentation.