GraphQL at OXID: More Posibilities through the new API

As an established store system, OXID eShop provides the basis for success for numerous online retailers. The system itself can be seen as a kind of foundation that can be expanded with new functions and interfaces as needed. When it comes to extensibility, OXID is now breaking new ground and relying on the GraphQL query language. In this blog post, you will learn what this is all about and why this combination is an extremely sensible one.

What is GraphQL?

GraphQL Logo

GraphQL is a query language in combination with a server-side runtime environment, which describes the course of time from the start of a program to its end, and which can be used to implement APIs (Application Programming Interfaces) for the integration of application software. Originally, GraphQL was developed by Facebook in 2012 and released three years later. Since 2018, the project has been under the umbrella of the non-profit Linux Foundation and is available to developers as open source. With GraphiQL, they can even access an independent development environment.

GraphQL Functionality

The idea behind GraphQL is that only the information that has actually been requested is output during a query. For this purpose, the developer of a GraphQL API defines a schema that contains all relevant fields and specifies which object types can be requested.

Each query to the API is validated against the schema, then the validated queries are executed by GraphQL. So-called resolvers are then used to assign values to the requested object types, for example by accessing a database.


GraphQL before REST: Why this decision pays off for OXID

Now that the function and purpose of GraphQL have been clarified, it makes sense to clarify a question that might arise: In principle, APIs could also be realized with REST, so why did OXID choose a different path and GraphQL?

Many comparisons á la GraphQL vs. REST are already spreading around the web, although the direct comparison between the two is somewhat misleading in and of itself. As mentioned elsewhere, GraphQL is a query language, while REST (Representational State Transfer) is “only” an architectural principle for network-based software.

There are several REST APIs for OXID. These are either open source solutions or individual interfaces in the course of projects. OXID eSales AG itself has not yet published an official REST API for connecting independent systems. The reason for this lies in the nature of “standardized” REST APIs, which are often fraught with the following problems in everyday life:

Overfetching: REST APIs tend to overfetch, which means that you receive more information as a result of a query than you actually need. A good example of this is the query of customer data: Imagine that you receive the name, address, contact of a responsible person and a customer number in response to your search query for specific customers, although you only wanted to find out the latter.

Underfetching: The pedant to overfetching is underfetching, from which a REST API is also not safe. Especially in special use cases, it can happen that a request provides too little information. For example, if you wanted to find out the order history in addition to the above-mentioned customer data, a second query would most likely be required as well, because you would have to retrieve your order information additionally. More queries are detrimental to performance, especially if both pieces of information are to be merged into one object in a complicated process.

Versioning: Changes to existing functions and new features mean that a REST API has to be versioned frequently in everyday business, which makes it more susceptible to compatibility problems.

GraphQL was developed for the very purpose of addressing these issues and is a good choice when it comes to providing an API as a base module to a large number of users.

Advantages of GraphQL

Minimization of requests: GraphQL resolves interdependencies of information and thus bundles several requests into only one request, which saves resources.

Output of only relevant information: GraphQL only returns data that has actually been requested. Thus, an existing system is not inflated by too much information, for example when new features are implemented.

Develop without version: Because the data query is flexible and reduced to relevant information only, new features can be implemented easily without affecting existing queries. This enables continuous development without versioning.

ESYON: In from the start

For many companies, GraphQL is still largely new territory – and OXID eSales AG is no exception. As an Enterprise Level Solution Partner, we are in constant exchange with the OXID team and have been there from the beginning when it comes to using GraphQL under OXID. For example, our developers took part in the OXID Coding Days, a partner event that focused on implementing a headless online store based on the GraphQL module. More information will follow shortly.

Your e-commerce platform with OXID eShop – contact us!

You are planning to use OXID eShop for your online store or to extend your existing OXID solution? ESYON is specialized in dealing with OXID eShop and custom development. Our solutions include, for example, the OXID eShop App and the P2O interface, which makes it possible to connect Perfion PIM to OXID.

In a non-binding initial appointment, we discuss the requirements for your project.

Contact us