Skip to content

Commit adbbc3f

Browse files
authored
Merge pull request #55 from graphql/http-edits
Better document the response format
2 parents 6910303 + 79481e6 commit adbbc3f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

site/docs/BestPractice-ServingOverHTTP.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ In addition to the above, we recommend supporting two additional cases:
5555

5656
If you're using express-graphql, you already get these behaviors for free.
5757

58+
### Response
59+
60+
Regardless of the method by which the query and variables were sent, the response should be returned in the body of the request in JSON format. As mentioned in the spec, a query might result in some data and some errors, and those should be returned in a JSON object of the form:
61+
62+
```js
63+
{
64+
"data": { ... },
65+
"errors": [ ... ]
66+
}
67+
```
68+
69+
If there were no errors returned, the `"errors"` field should not be present on the response. If no data is returned, [according to the GraphQL spec](http://facebook.github.io/graphql/#sec-Data), the `"data"` field should only be included if the error occurred during execution.
70+
5871
### GraphiQL
5972
GraphiQL is useful during testing and development but should be disabled in production by default. If you are using express-graphql, you can toggle it based on the NODE_ENV environment variable:
6073

0 commit comments

Comments
 (0)