graphql

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 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 (
	CmdAlter   = "alter"
	CmdAdmin   = "admin"
	CmdSchema  = "admin/schema"
	CmdQuery   = "graphql"
	CmdQueryPM = "query"
)

These commands represents the set of know graphql commands.

View Source
const (
	HTTP  = "http"
	HTTPS = "https"
)

These are the supported protocols.

Variables

This section is empty.

Functions

This section is empty.

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(protocol string, apiHost string, basicAuthToken string, client *http.Client) *GraphQL

New constructs a GraphQL for use to making queries agains a specified host. The apiHost is just the IP:Port of the Dgraph API endpoint.

func (*GraphQL) CreateSchema

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

CreateSchema performs a schema operation against the configured server.

func (*GraphQL) DropAll

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

DropAll perform an alter operatation against the configured server to remove all the data and schema.

func (*GraphQL) Mutate

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

Mutate performs a mutation operation against the configured server.

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) QuerySchema

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

QuerySchema performs a schema query operation against the configured 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