graphql

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 10 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/) and has some Dgraph specific support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithClient added in v1.4.4

func WithClient(client *http.Client) func(gql *GraphQL)

WithClient adds a custom client for processing requests.

func WithHeader added in v1.4.4

func WithHeader(key string, value string) func(gql *GraphQL)

WithHeader adds a key value pair to the header for requests.

func WithVariable added in v1.5.0

func WithVariable(key string, value interface{}) func(m map[string]interface{})

WithVariable allows for the submission of variables to the query.

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, 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) Query

func (g *GraphQL) Query(ctx context.Context, queryString string, response interface{}, variables ...func(m map[string]interface{})) error

Query performs a GraphQL query against the configured server.

func (*GraphQL) QueryEndpoint added in v1.5.1

func (g *GraphQL) QueryEndpoint(ctx context.Context, endpoint string, queryString string, response interface{}, variables ...func(m map[string]interface{})) error

QueryEndpoint performs a GraphQL query against the configured server at the specified endpoint from the base URL.

Jump to

Keyboard shortcuts

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