GraphQl
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
Of course, Testlum can test GraphQL queries.
GraphQL Integration
Description
<graphqlIntegration>
- command for integration with GraphQL
Required parameters
- alias - unique name of the integration
- url – URL to GraphQL API
- enabled – boolean flag to enable/disable integration (can be “true” or “false”)
All you need is to integrate with API by providing alias, the URL to the API, and enable the integration by switching the boolean flag to “true” in the integration.xml
file.
<graphqlIntegration>
<api alias="graphql" url="https://rickandmortyapi.com" enabled="true"/>
</graphqlIntegration>
How to send the query
Description
<graphql>
– command which is responsible for sending the GraphQL queries in testing scenarios
Required parameters
- Comment
- Alias
- Post or Get method
Required params for post method:
endpoint
body:
- from – file
- raw – string
response:
- code (default 200)
- file
- header (optional)
- name
- data
Required params for get method:
endpoint
param:
- name
- body
response:
- code (default 200)
- file
- header (optional):
- name
- data
Optional params for post/get methods:
- Header:
- name
- data
- response
- header
- body/param
<graphql comment="Check ability to get list of all books with POST method"
alias="ALIAS">
<post endpoint="/graphql">
<response code="200" file="expected_1.json"/>
<header name="Content-Type" data="application/json"/>
<body>
<from file="request_1.json"/>
</body>
</post>
</graphql>
<graphql comment="Check ability to get list of all books with GET method"
alias="ALIAS">
<get endpoint="/graphql">
<response code="200" file="expected_2.json"/>
<param name="query" data="{ getAllBooks { id author title number } }"/>
</get>
</graphql>