GraphQL integration
GraphQL is an alternative approach to compose data from multiple backend source using a query language as opposed to orchestrating multiple REST API calls. You can install GraphQL through Neptune DXP’s direct integration with the NPM package manager, a client library to handle the integration with a GraphQL server. The diagram below demonstrates a generic approach to some possible configurations:
The primary value of a GraphQL implementation is to simplify the data processed into a client, which often requires the gathering of data from multiple REST APIs requiring complex orchestrations. GraphQL eliminates this problem by organising data sources, resolving and composing their responses so that a client requests a single query and receive a corresponding single response with all the data within. In this indicative architecture a Neptune DXP application server has installed the popular Apollo GraphQL client which handles communication to the Apollo GraphQL server. The server then handles the connectivity to external APIs, such as a review engine, a Neptune DXP microservice fetching customer data ,and a legacy database. The client doesn’t have to worry about connecting each of the GraphQLs and lets the GraphQL server handle all the complexities.
The drawback with the above model is that the Neptune DXP application server is not able to use the data brokered through the GraphQL client to map it to the UX screen produced by the Neptune DXP App Designer. At this moment in time only data received through a REST or OData API can be used to automatically bind it to UI assets.
An alternative approach to resolve this may be an integration architecture, whereby a Neptune DXP microservice is placed between the Neptune DXP application server and the GraphQL server. The GraphQL server performs its duties as before but the proxy Neptune DXP microservice consumes the results of these queries and re-exposes through a REST API.
This then is consumed by the Neptune DXP application, allowing to fully bind the result of the GraphQL queries with UX assets produced by the Neptune DXP App Designer.
The penalty paid ought to be acceptable as the proxy should not need to perform any transformation to the resulting query data.