• Stars
    star
    933
  • Rank 48,976 (Top 1.0 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple low-level GraphQL HTTP client for Go

graphql GoDoc Build Status Go Report Card

Low-level GraphQL client for Go.

  • Simple, familiar API
  • Respects context.Context timeouts and cancellation
  • Build and execute any kind of GraphQL request
  • Use strong Go types for response data
  • Use variables and upload files
  • Simple error handling

Installation

Make sure you have a working Go environment. To install graphql, simply run:

$ go get github.com/machinebox/graphql

Usage

import "context"

// create a client (safe to share across requests)
client := graphql.NewClient("https://machinebox.io/graphql")

// make a request
req := graphql.NewRequest(`
    query ($key: String!) {
        items (id:$key) {
            field1
            field2
            field3
        }
    }
`)

// set any variables
req.Var("key", "value")

// set header fields
req.Header.Set("Cache-Control", "no-cache")

// define a Context for the request
ctx := context.Background()

// run it and capture the response
var respData ResponseStruct
if err := client.Run(ctx, req, &respData); err != nil {
    log.Fatal(err)
}

File support via multipart form data

By default, the package will send a JSON body. To enable the sending of files, you can opt to use multipart form data instead using the UseMultipartForm option when you create your Client:

client := graphql.NewClient("https://machinebox.io/graphql", graphql.UseMultipartForm())

For more information, read the godoc package documentation or the blog post.

Thanks

Thanks to Chris Broadfoot for design help.

More Repositories

1

appify

Create a macOS Application from an executable (like a Go binary)
Go
512
star
2

progress

io.Reader and io.Writer with progress and remaining time estimation
Go
409
star
3

remoto

Ultra-simple RPC ecosystem designed for right now.
Go
304
star
4

toys

Tools, scripts, toys, and utilities for Machine Box
Go
241
star
5

sdk-go

Official Go SDK for Machine Box
Go
144
star
6

desktop

Go/HTML/CSS/JS Desktop application scaffold.
Go
130
star
7

webFaceID

Use HTML5, Go and Facebox to implement face verification on a website
Go
59
star
8

webcamFacebox

Streaming from a webcam to facebox to do face recognition
Go
39
star
9

twitterfeed

Go channel providing live tweets containing search terms.
Go
35
star
10

videoanalysis

Webapp to process Video and do Face Recognition with Facebox
Go
32
star
11

visualsearch

Visual Search is a little app to find and cluster similar images using Tagbox
Go
31
star
12

mood

Twitter analytics using textbox
Go
14
star
13

textbox_elastic_indexer

Example how to pre-process news articles with textbox and index on Elastic Search
Go
13
star
14

machinebox-python-sdk

Python SDK for Machine Box services
Python
9
star
15

nevernude

Tool for stripping nudity from a video - Powered by Videobox + Nudebox
8
star
16

gopherconeu

Gophercon EU Machine Learning Workshop
Go
6
star
17

faceboxtools

Tools in Go for facebox, so you can quickly teach and tag based on folders
Go
4
star
18

issues

Machine Box issues, bugs and feature requests
2
star
19

ops

Operations
Makefile
2
star
20

womenwhogo

Women Who Go: workshop
Go
2
star
21

tagboxtools

Tools to tag and check images in your filesystem with tagbox
Go
1
star