From 195142fdce96f0cb33ab32cafb09cbc031bd0bb0 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Tue, 12 Jul 2022 10:27:54 +0100 Subject: [PATCH 1/2] Split 'invalid request body or parsing failure' into three examples --- spec/GraphQLOverHTTP.md | 29 +++++++++++++++++++++++------ spec/metadata.json | 4 +++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/spec/GraphQLOverHTTP.md b/spec/GraphQLOverHTTP.md index 60e0faa7..3678088e 100644 --- a/spec/GraphQLOverHTTP.md +++ b/spec/GraphQLOverHTTP.md @@ -537,17 +537,34 @@ The following examples provide guidance on how to deal with specific error cases when using the `application/graphql+json` media type to encode the response body: -##### Invalid parameters or parsing failure +##### JSON parsing failure -For example a POST response body of `NONSENSE` or `{"qeury": "{__typena`. +For example a POST response body of `NONSENSE` or `{"query":` (note: invalid +JSON). -Requests that do not constitute a well-formed GraphQL request should result in -status code `400` (Bad Request). +Requests that the server cannot interpret should result in status code `400` +(Bad Request). + +##### Invalid parameters + +For example a POST response body of `{"qeury": "{__typename}"}` (note: typo) or +`{"query": "query Q ($i:Int!) { q(i: $i) }", "variables": [7]}` (note: invalid +shape for `variables`). + +Requests that do not constitute a well-formed _GraphQL-over-HTTP request_ should +result in status code `400` (Bad Request). + +##### Document parsing failure + +For example a POST response body of `{"query": "{"}`. + +Requests where the _GraphQL document_ cannot be parsed should result in status +code `400` (Bad Request). ##### Document validation failure -Requests that fail to pass validation SHOULD be denied execution with a status -code of `400` (Bad Request). +Requests that fail to pass _GraphQL validation_ SHOULD be denied execution with +a status code of `400` (Bad Request). Note: In certain circumstances, for example persisted operations that were previously known to be valid, the server MAY attempt execution regardless of diff --git a/spec/metadata.json b/spec/metadata.json index b321cf88..b29048f0 100644 --- a/spec/metadata.json +++ b/spec/metadata.json @@ -6,7 +6,9 @@ "graphql-request": "#request", "graphql-response": "#sec-Response", "graphql-request-error": "#sec-Errors.Request-errors", - "graphql-field-error": "#sec-Errors.Field-errors" + "graphql-field-error": "#sec-Errors.Field-errors", + "graphql-document": "#sec-Document", + "graphql-validation": "#sec-Validation" } } } From 81869b3615e5cb7bcf499f145e52c06649fc5b7c Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Tue, 12 Jul 2022 18:05:53 +0100 Subject: [PATCH 2/2] Fix typos Co-authored-by: Gabriel McAdams --- spec/GraphQLOverHTTP.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/GraphQLOverHTTP.md b/spec/GraphQLOverHTTP.md index 3678088e..7d5891ca 100644 --- a/spec/GraphQLOverHTTP.md +++ b/spec/GraphQLOverHTTP.md @@ -539,7 +539,7 @@ body: ##### JSON parsing failure -For example a POST response body of `NONSENSE` or `{"query":` (note: invalid +For example a POST request body of `NONSENSE` or `{"query":` (note: invalid JSON). Requests that the server cannot interpret should result in status code `400` @@ -547,7 +547,7 @@ Requests that the server cannot interpret should result in status code `400` ##### Invalid parameters -For example a POST response body of `{"qeury": "{__typename}"}` (note: typo) or +For example a POST request body of `{"qeury": "{__typename}"}` (note: typo) or `{"query": "query Q ($i:Int!) { q(i: $i) }", "variables": [7]}` (note: invalid shape for `variables`).