Server can choose the media type on Accept fail#227
Conversation
| 1. Disregard the `Accept` header and respond with the server's choice of media | ||
| type, indicating this in the `Content-Type` header; OR |
There was a problem hiding this comment.
Would a suggestion make sense here? (if you're not sure what to choose, use application/json)
There was a problem hiding this comment.
The issue is that if you have a query that has deferred parts in it you have to respond with MultiPart/Mixed or an event stream.
There was a problem hiding this comment.
I think there’s enough context in the rest of the spec to infer the suggestion.
|
I thought we want the exact opposite? ~> graphql/defer-stream-wg#48 If the client cannot support a multipart response, and the accept header reflects this — then dont send it. For example using an older version of graphiql that doesn't support defer stream, but the server its targeting does. |
|
@maraisr that is exactly how I feel :D I would like it if we made it strict, so that if you send in the accept header that is what the server abides by. This would give predictability. If the server cannot meet the requested accept header it would be great if it would fail. But I think this is separate from this PR, this PR just refines already existing spec text and we can have a discussion on this in the next working group meeting or create another PR that discusses this. |
|
Yeah, this is just meant to be a fix; the major change in behaviour needs more discussion 👍 |
|
The "Accept" header is specified such that:
In the text currently we extend this same wording effectively to our server implementors; since GraphQL-over-HTTP's purpose is to map more natively to HTTP semantics. Having pondered this for a while now (!) I definitely see the value in honouring the Accept header and doing a 406 Not Acceptable; but this also severely limits the choices of servers - forcing them to reject the request otherwise they are not spec compliant. The client can (and should!) still check the I have a counter-proposal; we can say that the server SHOULD return a 406, but MAY ignore the header. This puts weight on the 406 approach, but does not forbid the "accept it anyway" approach. What are your thoughts on this @michaelstaib and @maraisr? |
|
My thoughts:
In conclusion, I agree with @benjie 's latest suggestion, that the spec should state that the server SHOULD return 406 (when the client requests an unsupported format), but MAY return any other format - both to mimic the HTTP spec and match the behavior when the |
|
I've updated the text to reflect this. |
d2167f3 to
a2509bb
Compare
If the client issues
Accept: application/graphql-response+json, application/jsonand the server does not support this for the request (e.g. the request uses@stream/@deferso needs a multipart response) then the server should be able to choose to respond with another suitable media type, for examplemultipart/mixed;type=application/graphql-response+json. Thanks to @michaelstaib for pointing out this oversight.(Note: v1 doesn't explicitly specify
@stream/@deferorsubscriptionrelated concerns, but we should still be future proof where possible.)