Back to All Questions
Question 60 of 100
Advanced API Testing
Advanced
Q60: How Do You Test GraphQL APIs in Postman?
🧬Core Concept
How Do You Test GraphQL APIs in Postman?
Key Takeaways & Architecture Summary
- ✓Select GraphQL as the request body format inside the client.
- ✓Define structured GraphQL queries or mutations directly in the editor.
- ✓Send queries via POST to a single endpoint (/graphql) and assert schemas.
Direct Answer Summary
To test GraphQL APIs in Postman, you send an HTTP POST request to the central `/graphql` endpoint, selecting "GraphQL" as the body format. You define your query or mutation schema inside the editor, passing variables and verifying the response structures.
⚠️ Senior Engineering Warning (Red Flag)
Never think GraphQL APIs use distinct HTTP verbs like PUT or DELETE. GraphQL queries and mutations are always sent as HTTP POST requests to a single endpoint, relying on the query payload to define actions.
💡 STAR Architectural Explanation & Pro Tip
GraphQL returns a 200 OK status code even when internal queries encounter exceptions. Automated scripts must check the response body for the `errors` array to confirm success.
RestAssuredTest.java
Rest-Assured + Java// Postman POST query payload representing GraphQL
// POST https://api.careerraah.com/graphql
query FetchJobProfile($jobId: ID!) {
job(id: $jobId) {
title
company
status
}
}