-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
queries with defer must have the Accept: multipart/mixed header #1610
Conversation
Since deferred responses can come back as multipart responses, we must check that the client supports that content type. This will allow older clients to show a meaningful error message instead of a parsing error if the `@defer` directive is used but they don't support it
This comment has been minimized.
This comment has been minimized.
it looks like rustfmt gives up on formatting |
@@ -153,7 +154,26 @@ where | |||
QueryPlannerContent::Plan { query, plan } => { | |||
let can_be_deferred = plan.root.contains_defer(); | |||
|
|||
if let Some(err) = query.validate_variables(body, &schema).err() { | |||
if can_be_deferred && !req.originating_request.headers().get_all(ACCEPT).iter().filter_map(|value| value.to_str().ok()).flat_map(|value| value.split(',') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a fine starting point but I'd suggest at least an issue-and-a-comment noting that this isn't a full spec complaint accept parser. (most importantly it will get confused if you have any "parameters" in accept like accept: multipart/mixed; foo=bar, application/json
; less importantly it can get even more confused if any parameters use quoted strings, like accept: application/json; someParam="foo, multipart/mixed, bar"
.)
(and yes, the way that parameters bind to types in Accept header involves semicolons that bind tighter than commas, unlike in English/French/etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this is something I planned to fix too. I'm a bit disappointed that the http crate does not provide a spec compliant iterator over values for well known headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm opening #1618 to track this
7d12590
to
cd544e7
Compare
the mediatype crate is used now, dismissing the review to unblock the release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's followup on the mime type dance though.
Follow up on #1610 rustfmt does not apply anymore on supergraph_service.rs, which is a hint that the code is way too complex. This PR moves the `Service:call` body to an async function, and splits part of the functionality
Fix #1618
Since deferred responses can come back as multipart responses, we must
check that the client supports that content type. This will allow older
clients to show a meaningful error message instead of a parsing error if
the
@defer
directive is used but they don't support it