{"repo":"shurcooL/graphql","free":true,"listed":false,"github":"https://github.com/shurcooL/graphql","clone":"git clone https://github.com/shurcooL/graphql.git","description":"Package graphql provides a GraphQL client implementation.","language":"Go","stars":731,"topics":["go","graphql","client"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"graphql ======= Package graphql provides a GraphQL client implementation. For more information, see package github.com/shurcooL/githubv4 , which is a specialized version targeting GitHub GraphQL API v4. That package is driving the feature development. Installation ------------ Usage ----- Construct a GraphQL client, specifying the GraphQL server URL. Then, you can use it to make GraphQL queries and mutations. Authentication Some GraphQL servers may require authentication. The graphql package does not directly handle authentication. Instead, when creating a new client, you're expected to pass an http.Client that performs authentication. The easiest and recommended way to do this is to use the golang.org/x/oauth2 package. You'll need an OAuth token with the right scopes. Then: Simple Query To make a GraphQL query, you need to define a corresponding Go type. For example, to make the following GraphQL query: You can define this variable: Then call client.Query , passing a pointer to it: Arguments and Variables Often, you'll want to specify arguments on some fields. You can use the graphql struct field tag for this. For example, to make the following GraphQL query: You can define this variable: Then call client.Query : However, that'll only work if the arguments are constant and known in advance. Otherwise, you will need to make use of variables. Replace the constants in the struct field tag with variable names: Then, define a variables map with their values: Finally, call client.","default_branch":null,"files":null,"tree":[],"storefront":"/r/shurcooL","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/shurcooL/graphql/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}