-
Notifications
You must be signed in to change notification settings - Fork 54
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
Defra Server GQL Endpoint Bugs Out Using GQL Clients #367
Comments
The quick fix I did that fixes this for a few clients (tested All the fix does is it parses the request body on a GET request. Probably not ideal, as discussed on our last call however, since we only use GET request right now, some of the GQL clients send the data in the request body when making a GET request. This would be cleaned up / hopefully be moved to a POST request as a sub-task of: #372 |
Also wanted to mention for example how the handler from https://github.com/graphql-go/handler works, obviously for The handler will accept requests with
GraphQL will first look for each parameter in the URL's query-string:
If not found in the query-string, it will look in the POST request body.
|
@shahzadlone if you want you can test it out with the HTTP API refactor branch https://github.com/sourcenetwork/defradb/tree/fredcarle/refactor/I372-http-api. We now accept both Get and Post request for the graphql endpoint. On a Get we parse the query parameter and on a Post we parse the request body. We assume |
I think As I mentioned above the method most GQL servers (like graphql-go/handler I mentioned above) look for POST request body after also checking the query parameter. Since your branch only does this on the GET request We are definitely following the GQL standard (the one @jsimnz posted: graphql.org/learn/serving-over-http) but the issue is different GQL clients do different things and obviously we can't tell them what to do LOL (maybe we can change some preferences within them? but I am using them in their default settings). One solution might be to do what I did in that commit: 8e93274 Basically, support query parameters and request body with both POST and GET requests, super quick and fast fix. This might seem non-sensible at first LOL but at least we won't have to worry about which GQL clients work with POST requests and which work with GET. This way our usage documentation also becomes simpler i.e. "use POST or GET they behave the same". Another reason to support my above suggestion would be when we open source, new users of DefraDB might already have committed to a certain GQL client which they don't want to switch from. The onboarding experience of things just working rather than tinkering around to find if to use GET or POST can be frustrating. There are exceptions where this can be bad, if we wanted to differentiate and provide different functionality with GET and POST for example to only limit Any who open to discussion, for other possible solutions. |
Resolves sourcenetwork#372 Resolves sourcenetwork#367 This PR restructures the api/http package with idiomatic patterns and a few useful utility functions.
Tried these and only Altair Client worked for me. I ensured that it was using
GET
request for all of them.On a little bit investigation found out that most of them (that didn't work) returned this error:
from:
query/graphql/planner/planner.go
The text was updated successfully, but these errors were encountered: