1

I'm used to testing "regular" REST API endpoints on daily basis, but currently I got into my first GraphQL API endpoint and I'm wondering are there any specifics that I should be aware of that are different from testing REST API endpoints ?

For example by specifics I mean should I test while querying all the data available in the schema or just the data that I need or both ?

1 Answer 1

1

GraphQL endpoint is just a REST endpoint that returns you some data in response to some input data. So in this abstract there is no any specific things to test. Like in any other endpoint there is some logic hidden behind so you need to apply your knowledge about that logic to design your specific tests.

6
  • REST is an architectural style, GraphQL endpoint can't be a REST endpoint, since it's a completely different thing.
    – Newcomer
    Commented Nov 7, 2018 at 11:08
  • @Newcomer it sure can. In what aspect GraphQL implementation contradicts REST conception?
    – Alexey R.
    Commented Nov 7, 2018 at 11:10
  • It doesn't contradict, it's just different. With REST you expect a static response from the endpoint almost always. unless something changes in the API itself and the response was modified, with GraphQL you query what you need in a single endpoint, so by definition you'll receive different data. Also main detail is that REST exposes endpoints with single resources, when GraphQL mostly does not, since it doesn't need to. Some might say that depending on how good your REST endpoint URL is, one can determine if that's according to the specification or not.
    – Newcomer
    Commented Nov 7, 2018 at 11:17
  • 1
    @Newcomer I am not sure I understand what you mean under static response. You can do something like GET /users?name=..&role=.. or GET /allobjects?type=...&name=...&etc=.... REST is not about what kind of resource you request. REST is REpresentationalStateTransfer which means that api calls do not change the state of the system and you have to provide the completed set of data to represent a particular state of a system with your request. So you cannot bring system from state A to B with one request and then bring the system from state B to C with another request. This is what REST about.
    – Alexey R.
    Commented Nov 7, 2018 at 23:49
  • Not sure I understand, but If you apply one of the CRUD operations to your system, for example you create something or delete something, then at that point you already change the system like you mentioned. Even though you modified it in small way, you still did. About static response, if you have a REST endpoint /users/:id that's the conventional way that will return userId, his name, address etc. that's static response, that particular endpoint always returns all user data, with GraphQL you can just query user's name when you need to, so the endpoint can just look users or smth.
    – Newcomer
    Commented Nov 8, 2018 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.