Skip to content
CodeKruPro

A GraphQL call returns 200: did it work?

QuizMedium

A GraphQL query returns HTTP 200 with this body:

{"data": {"order": null},
 "errors": [{"message": "Not authorised", "path": ["order"]}]}

What should the test conclude?

  • The query failed for the order field; GraphQL often reports errors in the errors array with HTTP 200, so tests must check errors and data, not only the status
  • The query succeeded because the status is 200
  • The server is broken because errors must use a 5xx code
  • The order does not exist, so the test passes

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in