graphql

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2020 License: MIT Imports: 10 Imported by: 0

README

Graphql Client

Another graphql written in go

Why

Coming from using graphql in node and python I found writing integration tests always very tedious and error prone.

This library is inspired by relay and other go code generation libraries like ent and gqlgen

Given a graphql schema and graphql queries this project will generate a type safe client

See this test for example use

Example

Given the Query

query TodosQuery {
  todos {
    id
    text
    done
    user {
      id
      name
    }
  }
}

Client Usage

client := Client{
	Url: "https://someserver.com",
}

data, err := client.TodosQuery()

... Consume the data

Quickstart

go get github.com/stackworx-go/graphql
go run github.com/stackworx-go/graphql/generate \
    --queries  "./**/*.graphql" \
    --schema schema.graphqls \
    --destination "./client.go" \
    --packageName "pkgname"

Known Issues and Limitations

  • One Query per file
  • Query names must be unique
  • Mutation Queries must end in Mutation, Queries must end in Mutation
  • Non inline fragments are not supported

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(queriesGlob, schemaFile, destination, packageName string) error

Generate Generate export

func GenerateWithSchema

func GenerateWithSchema(queriesGlob, destination, packageName string, schema *ast.Schema) error

GenerateWithSchema GenerateWithSchema export

Types

This section is empty.

Directories

Path Synopsis
cmd
Code generated for package internal by go-bindata DO NOT EDIT.
Code generated for package internal by go-bindata DO NOT EDIT.
integration
Code generated by github.com/stackworx-go/graphql, DO NOT EDIT.
Code generated by github.com/stackworx-go/graphql, DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL