Skip to content
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

Response to Deferred Query with Accept: multipart/mixed is application/json #1656

Closed
Tracked by #80
alessbell opened this issue Aug 30, 2022 · 6 comments · Fixed by #1652
Closed
Tracked by #80

Response to Deferred Query with Accept: multipart/mixed is application/json #1656

alessbell opened this issue Aug 30, 2022 · 6 comments · Fixed by #1652
Assignees

Comments

@alessbell
Copy link
Member

alessbell commented Aug 30, 2022

Describe the bug
When making a request containing a query with a @defer directive, e.g.

query DeferVariation {
  allProducts {
    delivery {
      ...MyFragment @defer
    }
    sku,
    id
  }
}

fragment MyFragment on DeliveryEstimates {
  estimatedDelivery
  fastestDelivery
}

and the request header Accept: multipart/mixed; deferSpec=20220822, application/json, the client would expect a response type of multipart/mixed, while it is receiving a response of type application/json.

This is the above query executed against apollographql/supergraph-demo-fed2#212 in Postman (NB: the default Accept: */* header is overridden by the custom Accept header at the bottom; when I uncheck the former the response is the same):

CleanShot 2022-08-30 at 16 38 51@2x

To Reproduce
There are detailed reproduction steps in the PR description jpvajda/ac-defer-example#5.

Expected behavior
If the @defer directive is issued on a fragment in the query and the client indicates it can handle multipart/mixed responses, the response will be multipart.

@glasser
Copy link
Member

glasser commented Aug 30, 2022

I think I see the bug

                list.any(|mime| mime.as_ref() == Ok(&multipart_mixed))

This Eq check compares to see if the types are exactly the same including parameters. You probably want to check to see if mime.essence() (which is the type without the parameters) equals multipart_mixed (and then of course look for deferSpec too).

@prasek
Copy link
Contributor

prasek commented Aug 30, 2022

adding deferSpec to smoke test 6 in PR 212 does result in the same error.

@abernix
Copy link
Member

abernix commented Aug 31, 2022

Thanks very much for opening this issue @alessbell. Do you mind confirming what version of the Router you were trying?

Presumably it was 1.0.0-alpha.0. It's worth noting that the Router still didn't have any awareness of deferSpec as of that version; such support is coming in #1652. So yes, what @glasser wrote is notable, but you're also sending more than we expect right now with the inclusion of deferSpec.

Anyhow, we'll take a look at this today and we'll get there soon! So close.

@glasser
Copy link
Member

glasser commented Aug 31, 2022 via email

@Geal
Copy link
Contributor

Geal commented Aug 31, 2022

ignoring unknown parameters should be fine yes, I'll update the filter

@Geal
Copy link
Contributor

Geal commented Aug 31, 2022

this should be fixed by #1652

@Geal Geal closed this as completed in 8410179 Aug 31, 2022
@abernix abernix mentioned this issue Sep 2, 2022
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants