github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/third_party/machinebox/graphql/README.md (about)

     1  # graphql [![GoDoc](https://godoc.org/github.com/machinebox/graphql?status.png)](http://godoc.org/github.com/machinebox/graphql) [![Build Status](https://travis-ci.org/machinebox/graphql.svg?branch=master)](https://travis-ci.org/machinebox/graphql) [![Go Report Card](https://goreportcard.com/badge/github.com/machinebox/graphql)](https://goreportcard.com/report/github.com/machinebox/graphql)
     2  
     3  Low-level GraphQL client for Go.
     4  
     5  * Simple, familiar API
     6  * Respects `context.Context` timeouts and cancellation
     7  * Build and execute any kind of GraphQL request
     8  * Use strong Go types for response data
     9  * Use variables and upload files
    10  * Simple error handling
    11  
    12  ## Installation
    13  Make sure you have a working Go environment. To install graphql, simply run:
    14  
    15  ```
    16  $ go get github.com/machinebox/graphql
    17  ```
    18  
    19  ## Usage
    20  
    21  ```go
    22  import "context"
    23  
    24  // create a client (safe to share across requests)
    25  client := graphql.NewClient("https://machinebox.io/graphql")
    26  
    27  // make a request
    28  req := graphql.NewRequest(`
    29      query ($key: String!) {
    30          items (id:$key) {
    31              field1
    32              field2
    33              field3
    34          }
    35      }
    36  `)
    37  
    38  // set any variables
    39  req.Var("key", "value")
    40  
    41  // set header fields
    42  req.Header.Set("Cache-Control", "no-cache")
    43  
    44  // define a Context for the request
    45  ctx := context.Background()
    46  
    47  // run it and capture the response
    48  var respData ResponseStruct
    49  if err := client.Run(ctx, req, &respData); err != nil {
    50      log.Fatal(err)
    51  }
    52  ```
    53  
    54  ### File support via multipart form data
    55  
    56  By default, the package will send a JSON body. To enable the sending of files, you can opt to
    57  use multipart form data instead using the `UseMultipartForm` option when you create your `Client`:
    58  
    59  ```
    60  client := graphql.NewClient("https://machinebox.io/graphql", graphql.UseMultipartForm())
    61  ```
    62  
    63  For more information, read the [godoc package documentation](http://godoc.org/github.com/machinebox/graphql).
    64  
    65  ## Thanks
    66  
    67  Thanks to [Chris Broadfoot](https://github.com/broady) for design help.