-
Notifications
You must be signed in to change notification settings - Fork 90
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
Generalize transport using an interface #2
Comments
Thanks, I'll definitely consider this. First, I'd like to understand it better.
Can you elaborate on how you do that? Also, are you interested in this for general GraphQL uses, or for GitHub GraphLQ API v4 as well? As far as I know, they only allow access over HTTP at this time. |
Currently, I am interested in using this as a general GraphQL client. In my case, I am using neelance/graphql-go to implement my GraphQL servers. I have a tiny package that uses modified generated GRPC code. My GRPC client is very simple: It has a It might seem weird that I am doing this over GRPC when HTTP would work, but GRPC provides a lot of useful features out of the box over HTTP and has a great ecosystem around it For example:
|
@F21, some updates here. First, I've factored out the general GraphQL client into a separate package https://github.com/shurcooL/graphql. So this issue belongs there now. Second, you said originally:
Can you tell me more about what you'd want the interface to look like. Would it be something like this? type Doer interface {
Do(req *http.Request) (*http.Response, error)
} We've used that at https://godoc.org/github.com/tambet/go-asana/asana#Doer. Finally, do you still need this? |
@shurcooL The GraphQL package looks great! I have decided not use GraphQL over GRPC. In terms of the interface, my original thoughts were to provide something more generalized, for example, request and response structs within the graphql package. For example, someone might not want to use http, but build their own layer on top of TCP. Having said that, I don't really need this anymore, so maybe we should close this issue and open a new one when the need arises in the future? |
I see.
That sounds like the best way to proceed, let's do that. Thanks! |
As far as I know, GraphQL protocol is usually implemented on top of HTTP. It uses HTTP methods like |
The current implementation supports using a
http.Client
. As discussed in #1, it would be nice if there is a transport interface, so that users of the package can implement their own transport.In my case, I am using graphql over GRPC. GRPC is built on top of
http.Client
and thehttp.Client
is not used directly. Instead, the a GRPC connection is passed to the generated GRPC client. For a simple example see: https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_client/main.goI'd imagine that the interface should be quite low level and "close to the wire". In other words, transports should not have to know too much about how graphql works.
The text was updated successfully, but these errors were encountered: