With increasing usage of cloud-based services and the rapid development of mobile devices the need for quick and lightweight data fetching rises. But to be able to deliver a seamless and effective experience for users and clients, it is necessary that the communication between applications on the internet can maintain a high quality. A common technology for communications between web services is Representational State Transfer (REST) architecture. REST entails restrictions that can reduce the ability to design flexible web services, which can mean a degraded performance with longer response times. Alternative solutions have begun to emerge, including the query language GraphQL, which has been developed with the aim of stretching the limitations that previously existed and thus achieving a different flexibility. To contribute with aresult that was applicable with different types of database solutions, GraphQL and REST were tested with both a relational- and a non-relational database.
In this study, a comparison of performance with different types of queries was performed to evaluate whether GraphQL can contribute with flexibility while maintaining an equivalent performance. The study was based on measuring latency and data volume for a more or less complex set of requests.
The results showed that GraphQL performs better than REST in terms of latency when more than one endpoint is used for REST. At only one endpoint, REST, when using both a SQL- and a NoSQL database, is faster than its GraphQL counterpart. In terms of data volume, REST performs better than GraphQL in all cases. When requesting data from four endpoints in REST, GraphQL has a smaller data volume than REST NoSQL, but REST SQL is still the smallest.
GraphQL with SQL a database performs better than GraphQL with NoSQL database, in terms of both latency and data volume, in all cases. In terms of latency, REST with NoSQL database performs better than REST with a SQL database in three cases out of four. In terms of data volume, REST with a SQL database performs better than REST with a NoSQL database in all cases both in size of request and size of response.