Skip to content

Commit a1e6d8c

Browse files
authored
Clarify well-formed response and fix links to GraphQL response spec (#231)
1 parent 466f5db commit a1e6d8c

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

spec/GraphQLOverHTTP.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ using the JSON encoding for GraphQL requests:
183183
| ------------------ | --------------------------------------- |
184184
| `application/json` | Standard type for GraphQL JSON requests |
185185

186-
And for GraphQL responses:
186+
And for a _GraphQL response_:
187187

188188
| Name | Description |
189189
| ----------------------------------- | ------------------------------------------------------------------ |
@@ -401,10 +401,10 @@ And the body:
401401

402402
# Response
403403

404-
When a server receives a _GraphQL-over-HTTP request_, it must return a
405-
well‐formed response. The server's response describes the result of validating
406-
and executing the requested operation if successful, and describes any errors
407-
encountered during the request.
404+
When a server receives a well-formed _GraphQL-over-HTTP request_, it must return
405+
a well‐formed _GraphQL response_. The server's response describes the result of
406+
validating and executing the requested operation if successful, and describes
407+
any errors encountered during the request.
408408

409409
A server must comply with
410410
[RFC7231](https://datatracker.ietf.org/doc/html/rfc7231).
@@ -478,7 +478,7 @@ algorithm.
478478
## Status Codes
479479

480480
In case of errors that completely prevent the generation of a well-formed
481-
GraphQL response, the server SHOULD respond with the appropriate status code
481+
_GraphQL response_, the server SHOULD respond with the appropriate status code
482482
depending on the concrete error condition.
483483

484484
Note: Typically this will be the `400` (Bad Request) status code.
@@ -500,11 +500,11 @@ error_ or _GraphQL field error_ raised.
500500
Note: A status code in the `4xx` or `5xx` ranges or status code `203` (and maybe
501501
others) could originate from intermediary servers; since the client cannot
502502
determine if an `application/json` response with arbitrary status code is a
503-
well-formed GraphQL response (because it cannot trust the source) the server
503+
well-formed _GraphQL response_ (because it cannot trust the source) the server
504504
must use `200` status code to guarantee to the client that the response has not
505505
been generated or modified by an intermediary.
506506

507-
If the GraphQL response contains a non-null {data} entry then the server MUST
507+
If the _GraphQL response_ contains a non-null {data} entry then the server MUST
508508
use the `200` status code.
509509

510510
Note: This indicates that no _GraphQL request error_ was raised, though one or
@@ -524,35 +524,36 @@ type.
524524
This section only applies when the response body is to use the
525525
`application/graphql-response+json` media type.
526526

527-
If the GraphQL response contains the {data} entry and it is not {null}, then the
528-
server MUST reply with a `2xx` status code and SHOULD reply with `200` status
529-
code.
527+
If the _GraphQL response_ contains the {data} entry and it is not {null}, then
528+
the server MUST reply with a `2xx` status code and SHOULD reply with `200`
529+
status code.
530530

531531
Note: The result of executing a GraphQL operation may contain partial data as
532532
well as encountered errors. Errors that happen during execution of the GraphQL
533533
operation typically become part of the result, as long as the server is still
534-
able to produce a well-formed response. There's currently not an approved HTTP
535-
status code to use for a "partial response," contenders include WebDAV's status
536-
code "207 Multi-Status" and using a custom code such as "247 Partial Success."
534+
able to produce a well-formed _GraphQL response_. There's currently not an
535+
approved HTTP status code to use for a "partial response," contenders include
536+
WebDAV's status code "207 Multi-Status" and using a custom code such as "247
537+
Partial Success."
537538
[IETF RFC2616 Section 6.1.1](https://datatracker.ietf.org/doc/html/rfc2616#section-6.1.1)
538539
states "codes are fully defined in section 10" implying that though more codes
539540
are expected to be supported over time, valid codes must be present in this
540541
document.
541542

542-
If the GraphQL response contains the {data} entry and it is {null}, then the
543+
If the _GraphQL response_ contains the {data} entry and it is {null}, then the
543544
server SHOULD reply with a `2xx` status code and it is RECOMMENDED it replies
544545
with `200` status code.
545546

546547
Note: Using `4xx` and `5xx` status codes in this situation is not recommended -
547548
since no _GraphQL request error_ has occurred it is seen as a "partial
548549
response".
549550

550-
If the GraphQL response does not contain the {data} entry then the server MUST
551+
If the _GraphQL response_ does not contain the {data} entry then the server MUST
551552
reply with a `4xx` or `5xx` status code as appropriate.
552553

553554
Note: The GraphQL specification indicates that the only situation in which the
554-
GraphQL response does not include the {data} entry is one in which the {errors}
555-
entry is populated.
555+
_GraphQL response_ does not include the {data} entry is one in which the
556+
{errors} entry is populated.
556557

557558
If the GraphQL request is invalid (e.g. it is malformed, or does not pass
558559
validation) then the server SHOULD reply with `400` status code.
@@ -640,6 +641,6 @@ response; it still indicates successful execution.
640641

641642
If the response uses a non-`200` status code and the media type of the response
642643
payload is `application/json` then the client MUST NOT rely on the body to be a
643-
well-formed GraphQL response since the source of the response may not be the
644+
well-formed _GraphQL response_ since the source of the response may not be the
644645
server but instead some intermediary such as API gateways, proxies, firewalls,
645646
etc.

0 commit comments

Comments
 (0)