graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

Use GET method instead of POST method when sending query

Open rr-jung-chang opened this issue 3 years ago • 2 comments

Sorry for duplicate if this issue has already been brought up. Can we add support to enable GraphiQL to send request via GET method? Most GraphQL server implementations support both GET and POST. Our GraphiQL is using POST by default. Would be great to use GET.

rr-jung-chang avatar Sep 13 '22 21:09 rr-jung-chang

This is currently possible by passing in your own fetcher.

That said, passing in a METHOD option to the default fetcher seems like it could be a reasonable upgrade. @acao, do you see any downsides to implementing an optional METHOD option, with a default of POST, in the fetcher?

jonathanawesome avatar Sep 14 '22 17:09 jonathanawesome

@jonathanawesome indeed, I was going to suggest the same thing. I was thinking that createGraphiQLFetcher() can accept a enableQueryGET boolean, ala enableIncrementalDelivery option.

This is even included in the official transport spec!

and MAY accept other HTTP methods, such as GET.

so from a spec completion perspective, this is almost a bug report, instead of a feature request!

acao avatar Sep 14 '22 18:09 acao

@jonathanawesome @acao hi i was just struggling to get this working. i'm trying to make a GET request with the query, however it just returns the graphiql UI. is there a way i can make that request without using a fetcher? i have a restriction meaning i can only specify a URL unfortunately :/ any help would be greatly appreciated! thanks :D

JankOops avatar Dec 12 '22 11:12 JankOops

@JankOops if you don't control the GraphiQL implementation (i.e. if you use GraphiQL provided by a third-party API), it's not possible to configure sending GET requests through the UI. I also think that is the correct way. If the API does not support GET requests for whatever reason, it makes little sense that GraphiQL would allow sending that request.

Looking at the draft for the GraphQL over HTTP spec, it also only required support for POST and marks support for GET as optional.

thomasheyenbrock avatar Mar 31 '23 13:03 thomasheyenbrock