@@ -15,12 +15,18 @@ equivalent functionality, but rely on blocking vs non-blocking I/O respectively
15
15
writing the HTTP response.
16
16
17
17
Requests must use HTTP POST with `"application/json"` as content type and GraphQL request details
18
- included as JSON in the request body, as defined in the proposed
18
+ included as JSON in the request body. Clients can request the `"application/graphql-response+json"` media type
19
+ to get the behavior defined in the official
19
20
https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md[GraphQL over HTTP] specification.
20
- Once the JSON body has been successfully decoded, the HTTP response status is always 200 (OK),
21
+ If the client doesn't express any preference, this will be the content type of choice.
22
+ Clients can also request the legacy `"application/json"` media type to get the traditional HTTP behavior.
23
+
24
+ In practice, GraphQL HTTP clients should expect 4xx/5xx HTTP responses if the server is unavailable, security credentials
25
+ are missing or if the request body is not valid JSON. `"application/graphql-response+json"` responses will also use
26
+ 4xx statuses if the GraphQL document sent by the client cannot be parsed or is considered invalid by the GraphQL engine.
27
+ In this case, `"application/json"` responses will still use 200 (OK).
28
+ Once the GraphQL request has been successfully validated, the HTTP response status is always 200 (OK),
21
29
and any errors from GraphQL request execution appear in the "errors" section of the GraphQL response.
22
- The default and preferred choice of media type is `"application/graphql-response+json"`, but `"application/json"`
23
- is also supported, as described in the specification.
24
30
25
31
`GraphQlHttpHandler` can be exposed as an HTTP endpoint by declaring a `RouterFunction`
26
32
bean and using the `RouterFunctions` from Spring MVC or WebFlux to create the route. The
0 commit comments