graphql

package module
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 30

README

graphql

Simple GraphQL client for executing mutations and queries.

CircleCI

Copyright 2020, Ardan Labs
info@ardanlabs.com

Licensing

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About The Project

Package graphql provides support for executing mutations and queries against a database using GraphQL. It was designed specifically for working with Dgraph.

All of the documentation can be found on the go.dev website.

Documentation

Overview

Package graphql provides support for executing mutations and queries against a database using GraphQL. It was designed specifically for working with [Dgraph](https://dgraph.io/).

Index

Constants

View Source
const (
	CmdAdmin   = "admin"
	CmdQuery   = "graphql"
	CmdQueryPM = "query"
)

These commands represents the set of know graphql commands.

Variables

This section is empty.

Functions

func WithAuth added in v1.4.0

func WithAuth(authHeaderName string, authToken string) func(gql *GraphQL)

WithAuth adds authentication parameters to the graphql client.

Types

type GraphQL

type GraphQL struct {
	// contains filtered or unexported fields
}

GraphQL represents a system that can accept a graphql query.

func New

func New(url string, client *http.Client, options ...func(gql *GraphQL)) *GraphQL

New constructs a GraphQL for use to making queries agains a specified host. The url is the fully qualifying URL without the /graphql path.

func (*GraphQL) Do added in v1.4.1

func (g *GraphQL) Do(ctx context.Context, command string, r io.Reader, response interface{}) error

Do provides the mechanics of handling a GraphQL request and response.

func (*GraphQL) Query

func (g *GraphQL) Query(ctx context.Context, queryString string, response interface{}) error

Query performs a GraphQL query against the configured server.

func (*GraphQL) QueryPM

func (g *GraphQL) QueryPM(ctx context.Context, queryString string, response interface{}) error

QueryPM performs a GraphQL+- query against the configured Dgraph server.

func (*GraphQL) QueryWithVars

func (g *GraphQL) QueryWithVars(ctx context.Context, command string, queryString string, queryVars map[string]interface{}, response interface{}) error

QueryWithVars performs a query against the configured server with variable substituion.

Jump to

Keyboard shortcuts

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