Sredny M Casanova
Sredny M Casanova

Reputation: 5053

Consume GraphQL service from a Golang app

I have a Go Application that needs to consume a GraphQL service, now the documentation of graphQL is more oriented to the GraphQL server and not as a client. How can I do that?

I checked this example but some things are not clear to me:

Upvotes: 2

Views: 1341

Answers (2)

CGS
CGS

Reputation: 2872

One of the module that I would recommend is shurcool

client = graphql.NewClient("http://<<graphqlEndpoint>>", nil)

err := client.Query(context.Background(), &query, nil)
if err != nil {
    // Handle error.
}
fmt.Println(query.Me.Name)

Upvotes: 1

Vinicius Souza
Vinicius Souza

Reputation: 445

You should check this project: https://github.com/machinebox/graphql .

If you don't want to use an external library inside in your project, you could look the code and see how can you implement a simple client.

Upvotes: 2

Related Questions