Apollo-server: Support GET requests

Created on 2 Sep 2016  ·  8Comments  ·  Source: apollographql/apollo-server

Right now apolloServer supports only POST requests, which makes its code really simple. However, sometimes it can be useful to send a GET request to a GraphQL server, because more devices support them, and because they make HTTP caching mechanisms easy to use. We should also support those use-cases.

Arguments should either all be in the URL, or all in the body. It shouldn't be possible to mix the two. Maybe we should say that if it's a POST request it has to be in the body, and if it's a GET request, it has to be in the URL?

🧞‍♂️ enhancement

Most helpful comment

@uhoh-itsmaciek yeah, that's the plan:

  • params exclusively in the url for GET
  • params exclusively in the body for POST

All 8 comments

@helfer so I think if we are going to support get requests they arguments should be required to be in the URL that way one of the benefits you mention "HTTP caching" will work. I don't like the idea of supporting a body in the GET. Anyway I might find sometime in the next couple of days to look into this further.

GET request bodies are pretty unusual (if not exactly in violation of the standard)--having params in the URL would be much more idiomatic. Having GET request support would be great, though.

@uhoh-itsmaciek yeah, that's the plan:

  • params exclusively in the url for GET
  • params exclusively in the body for POST

Having GET would be great. This caught me out when first playing with Apollo Server as I'd just been reading through the GraphQL HTTP docs which talks about support for both GET and POST. I did see that the _Koa_ example demonstrates that this is on the POST request but I missed this at first (Hapi user).

_Totally digging this project - thank you._

Yeah I wasn't a big fan of the GraphQL docs having lots of different ways to send queries, but since it does we should support all of them.

👍 for this feature!

👍 - I unfortunately have to swap out apollo server for express-graphql for now, since CloudFront doesn't cache POSTs.

@jarwol, the code for GET support is almost ready to be merged.. stay tuned ;)

Was this page helpful?
0 / 5 - 0 ratings