GraphQL is a great query language for APIs which lets TravelgateX communicate its business model to all partners effectively.
Some GraphQL features used at TravelgateX:
However, some GraphQL features have consequences on performance because most of the intensive workloads are executed in GraphQL backends. We have detected this performance degradation in scenarios returning responses with +10000 nodes and/or +1Mb size.
Specifically, backend services performance degradation is related to CPU usage to support GraphQL features as:
These features facilitate Front-Back GraphQL development for frameworks like React or Angular. However, in the case of a Back-Back GraphQL implementation, developers don’t use a specific GraphQL client, they generally use well-known common HTTP client libraries.
So, the challenge is how to offer the best of two worlds:
And these are the good news: it’s all about JSON!
TravelgateX backend servers will be notified by the client application and will return a valid JSON response conforming GraphQL schema, which will not support all of the restrictions defined in the GraphQL specification.
Objectives:
Since TravelgateX GraphQL implementation already uses JSON in the response as recommended in GraphQL Best Practices, the solution is to return responses that do not use GraphQL specific features. The client’s JSON parser should expect:
To activate this mode, the client application must add the HTTP header TGX-Content-Type:graphqlx/json in the request:
curl -X POST -H "Content-Type:application/json" -H "TGX-Content-Type:graphqlx/json" -H "Authorization: Apikey [MY_API_KEY]" --data @data_file.txt --compressed https://api.travelgatex.com
When expecting to receive +10000 nodes in a non-paginated query, backend developers should use the header specified above.
This will only happen in the scenarios described below:
If you are unsure about previous scenarios use the header in all hotelX.search queries.
To implement this feature, please follow these steps:
The GraphQL community is focusing on improving the performance issues flagged by different users, but for us time to market is critical, so we are getting ahead of the game and putting in place our own solutions to handle large responses using GraphQL.
The performance degradation has been detected and fixed. TravelgateX will continue to strive to offer the best performance possible, offering alternative connectivity protocols for our clients. We’ll use Google Cloud API development approach, advising our clients of the best protocol for each use case.