-
Notifications
You must be signed in to change notification settings - Fork 1
14 integration testing
maapteh edited this page Jun 18, 2020
·
1 revision
[Test]
Continue from branchchapter-13-solution
An important part of testing are integration or e2e tests. For our GraphQL API we can define these using Postman or any other HTTP testing tool.
GraphQL queries and mutations are sent to the server as POST
requests. The body of the request contains the query data:
{
"query": "query myQuery($id: id) { myQuery { myData } }",
"variables": { "id": 9001 },
"operationName": "myQuery"
}
This could of course also be a mutation.
To illustrate using cURL
:
curl --location --request POST 'http://localhost:3007/api/graphql' \
--header 'Content-Type: application/json' \
--data-raw '{ "query": "query myQuery(\$id: id) { myQuery { myData } }" }'
To finish this chapter, implement an integration test using Postman or a tool of your choice. And make an assertion on the returned data that confirms it's performing the query correctly
Branch chapter-14-solution
See postman collection in tests
.