graphql-request icon indicating copy to clipboard operation
graphql-request copied to clipboard

Add support for GET requests

Open forabi opened this issue 6 years ago • 9 comments

Fixes #61

forabi avatar Mar 30 '18 13:03 forabi

Hmm, the universal-url package is pretty big. I'm not sure how to proceed. Should I use universal-url-lite instead which has some caveats? Or should I just add a note to README to let downstream consumers that a URL polyfill is required?

forabi avatar Apr 03 '18 15:04 forabi

Hmm given that it's a fairly rare use case that you'd query a GraphQL server via GET + universal-url seems to add some significant size increase, I'm not sure whether we should add this in order to keep the package small.

Other thoughts?

schickling avatar Apr 07 '18 16:04 schickling

I actually changed the implementation to use the built-in Node.js url and querystring modules since URL always requires an absolute URL and throws an error when the URL is relative. We are using GET for non-private data to be able to cache the responses at the CDN level (relevant discussion). POST requests are not cachable.

Of course, using url and querystring means that using this library requires bundling with Webpack/Browserify/Rollup. So this solution isn't perfect either.

Please feel free to close this if you don't think it's something you would want to support.

forabi avatar Apr 07 '18 16:04 forabi

Thanks a lot for elaborating @forabi – you use case makes sense.

I'd like to keep this open a bit longer to hear thoughts of other people before making a decision. Maybe you'd want to publish a fork in the meanwhile?

schickling avatar Apr 07 '18 16:04 schickling

Maybe you'd want to publish a fork in the meanwhile?

I already did :smile: (@forabi/graphql-request)

forabi avatar Apr 07 '18 16:04 forabi

@schickling It just occurred to me that this library already requires bundling since it's import-ing cross-fetch.

forabi avatar Apr 16 '18 22:04 forabi

Is there any progress on this? I really need this feature 😄

mara-schulke avatar Oct 19 '19 20:10 mara-schulke

Prismic GraphQL API is using GET rather than POST for their requests, so I'm unable to use this library because GET is not supported. Is there any plan to incorporate this based on the latest @forabi's comment?

marbiano avatar Jul 03 '20 03:07 marbiano

Any news about 'GET' requests ?

arnaudmanaranche avatar Feb 10 '21 09:02 arnaudmanaranche