federation icon indicating copy to clipboard operation
federation copied to clipboard

add application/graphql+json mimeType support to gateway

Open eformat opened this issue 3 years ago • 6 comments

Add support for application/graphql+json to gateway.

I know this is not universally accepted yet, and there are related fixes in progress

https://github.com/graphql/graphql-over-http/issues/31 https://github.com/apollographql/apollo-server/pull/6295

This issue comes up when using apollo gateway with popular Java microservices frameworks that set application/graphql+json e.g. https://github.com/smallrye/smallrye-graphql is one such framework

eformat avatar Apr 23 '22 00:04 eformat

@eformat: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

apollo-cla avatar Apr 23 '22 00:04 apollo-cla

Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
Latest commit 3914bb4a1732361d971fb2ebf71ddeb167e4c475

netlify[bot] avatar Apr 23 '22 00:04 netlify[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codesandbox-ci[bot] avatar Apr 23 '22 00:04 codesandbox-ci[bot]

@eformat: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Done. Thanks.

eformat avatar Apr 23 '22 02:04 eformat

Thanks for the contribution.

I'll admit that I'm personally just a little bit unsure about adding application/graphql+json explicitely because:

  1. the whole graphql-over-http effort is still Stage 0, and the stages description kind of suggest that it's "reasonable to start implementations" only at stage 1.
  2. I haven't had time to really follow that proposal, and afacit most of the main maintainers of this repo are currently on that same boat, so while I get the general idea, I want to be cautious about accepting something I don't understand all that well.

But to be very clear, I understand that this is very far from a full implementation, and is in fact a super trivial change with relatively little "strings attached". So I'm not trying to be contrarian on principle. Rather, I'm trying to justify my position, which is that while I'm happy to facilitate early experiments with that graphql-over-http proposal if it's easy, I also think that it's way too early for federation/the gateway to "officially" support it, and so I'd like to be careful with managing expectations.

All this to say that I'd presonally prefer to change the content type detection for json to be something along the lines of (contentType.startsWith('application/') && contentType.includes('json')) (or maybe contentType.endsWith('json') for the latter? Which I'll note was actually an offline idea from @abernix). I feel that it's what you'd roughtly expect, and it avoids hardcoding the currently unofficial/un-registered application/graphql+json (and to my earlier rambling, may more strongly suggest some kind of official support).

pcmanus avatar Apr 28 '22 08:04 pcmanus

@pcmanus - yeah, look i hear you. adjusted to use contentType.includes('json') which seems sane.

eformat avatar Apr 28 '22 23:04 eformat

Thanks for the PR. Closing this old PR with the same reason as on https://github.com/apollographql/federation/pull/2769#issuecomment-1706891804

dariuszkuc avatar Oct 13 '23 17:10 dariuszkuc