The Test Bed has now made available a new service to validate GraphQL queries against GraphQL schemas. The new service can be used for standalone validation and as a building block in conformance test cases.
GraphQL is a popular new technology that is revolutionising how APIs are accessed. It includes a query language for APIs and a server-side execution runtime that allows queries and operations on an API’s data based on a well-defined type system, expressed as a GraphQL schema. GraphQL allows web applications to replace their numerous REST endpoints by a single GraphQL entry point that serves all API requests. From the perspective of clients, access is more intuitive given that all data and operations are precisely defined by the client as part of a single query, and more lightweight given that complete information can now be obtained by one GraphQL request, replacing potentially numerous individual REST calls.
The Test Bed now offers support for projects using GraphQL by launching a new GraphQL validator to validate queries against their target schemas. The validator is based on the GraphQL reference implementation and expects as input the query to validate as well as the target schema. Both can be provided directly or as remote URI references, with the schema also being able to be pre-configured to provide a fixed validator for a specific project’s API.
The validator is accessible via the following channels:
- REST API, allowing machine-to-machine use and well as use via the web user interface offered by the API’s Swagger documentation.
- SOAP web service API, allowing SOAP-based machine-to-machine integration but also use by the Test Bed in conformance test scenarios implemented as GITB TDL test cases.
The GraphQL validator offers a powerful tool for the developers of API clients that can now validate their queries against their target API’s schema. It also provides a conformance testing building block through its integration with the Test Bed, as it allows query validation to be made as part of any messaging workflow. Moreover, including scenario-specific schemas in test cases makes it possible to validate ad-hoc business rules by providing them to the validator alongside the queries to validate.
The GraphQL validator is one of the numerous services offered by the Interoperability Test Bed in support of conformance testing. For more information on the Test Bed check its Joinup space with its value proposition being a good starting point for newcomers. Finally, to remain updated of all the latest Test Bed news: