-
Notifications
You must be signed in to change notification settings - Fork 2
Postman & GraphQL
Ben Weese edited this page Jun 21, 2019
·
1 revision
For those who need to test GraphQL you can now use Postman Canary which is Postman's beta version. Which means this will be coming to a postman near you in the future. Now under body is a GraphQL where you can add your query, you can read more here.
query{
allFilms
{
films {
id
title
episodeID
}
}
}
This will then work so you can test the json body like normal. You will have to use nested objects more though as everything will be more layers deep.
pm.test("Has correct schema", function() {
pm.expect(jsonData.data.allFilms.films).to.be.a("array");
for(var i=0; i<jsonData.data.allFilms.films.length; i++){
pm.expect(jsonData.data.allFilms.films[i].id).to.be.a("string");
pm.expect(jsonData.data.allFilms.films[i].title).to.be.a("string");
pm.expect(jsonData.data.allFilms.films[i].episodeID).to.be.a("number");
}
});