Skip to content

Commit cabdc15

Browse files
benjieghmcadams
andauthored
Split 'invalid request body or parsing failure' into three examples (#200)
* Split 'invalid request body or parsing failure' into three examples * Fix typos Co-authored-by: Gabriel McAdams <[email protected]> Co-authored-by: Gabriel McAdams <[email protected]>
1 parent f2d721d commit cabdc15

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

spec/GraphQLOverHTTP.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,34 @@ The following examples provide guidance on how to deal with specific error cases
544544
when using the `application/graphql+json` media type to encode the response
545545
body:
546546

547-
##### Invalid parameters or parsing failure
547+
##### JSON parsing failure
548548

549-
For example a POST response body of `NONSENSE` or `{"qeury": "{__typena`.
549+
For example a POST request body of `NONSENSE` or `{"query":` (note: invalid
550+
JSON).
550551

551-
Requests that do not constitute a well-formed GraphQL request should result in
552-
status code `400` (Bad Request).
552+
Requests that the server cannot interpret should result in status code `400`
553+
(Bad Request).
554+
555+
##### Invalid parameters
556+
557+
For example a POST request body of `{"qeury": "{__typename}"}` (note: typo) or
558+
`{"query": "query Q ($i:Int!) { q(i: $i) }", "variables": [7]}` (note: invalid
559+
shape for `variables`).
560+
561+
Requests that do not constitute a well-formed _GraphQL-over-HTTP request_ should
562+
result in status code `400` (Bad Request).
563+
564+
##### Document parsing failure
565+
566+
For example a POST response body of `{"query": "{"}`.
567+
568+
Requests where the _GraphQL document_ cannot be parsed should result in status
569+
code `400` (Bad Request).
553570

554571
##### Document validation failure
555572

556-
Requests that fail to pass validation SHOULD be denied execution with a status
557-
code of `400` (Bad Request).
573+
Requests that fail to pass _GraphQL validation_ SHOULD be denied execution with
574+
a status code of `400` (Bad Request).
558575

559576
Note: In certain circumstances, for example persisted operations that were
560577
previously known to be valid, the server MAY attempt execution regardless of

spec/metadata.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"graphql-request": "#request",
77
"graphql-response": "#sec-Response",
88
"graphql-request-error": "#sec-Errors.Request-errors",
9-
"graphql-field-error": "#sec-Errors.Field-errors"
9+
"graphql-field-error": "#sec-Errors.Field-errors",
10+
"graphql-document": "#sec-Document",
11+
"graphql-validation": "#sec-Validation"
1012
}
1113
}
1214
}

0 commit comments

Comments
 (0)