graphql

package
v0.0.0-...-fbe9a17 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGraphQLArray

func BuildGraphQLArray(arr []string) string

BuildGraphQLArray builds a GraphQL array for including in queries or mutations.

func BuildGraphQLEnumArray

func BuildGraphQLEnumArray(v interface{}) string

BuildGraphQLEnumArray creates an array for values which can be represented as enums in GraphQL, i.e. do not need to be surrounded by strings.

func MarshalGQL

func MarshalGQL(v interface{}) string

MarshalGQL returns the GraphQL representation of v.

Types

type Client

type Client interface {
	URL() string
	Do(ctx context.Context, req *Request) (*Response, error)
}

Client is a GraphQL endpoint client.

type DefaultClient

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

func NewClient

func NewClient(_url string, headers map[string]string) (*DefaultClient, error)

func (*DefaultClient) Do

func (client *DefaultClient) Do(ctx context.Context, req *Request) (*Response, error)

func (*DefaultClient) URL

func (client *DefaultClient) URL() string

type Error

type Error struct {
	Message   string `json:"message"`
	Locations []struct {
		Line   int `json:"line"`
		Column int `json:"column"`
	} `json:"locations"`
}

Error is an error returned from the database for a GraphQL query.

type Marshaller

type Marshaller interface {
	GQL() string
}

Marshaller defines an ability for a type to represent itself in GraphQL.

type Request

type Request struct {
	Query         string                 `json:"query"`
	OperationName string                 `json:"operationName,omitempty"`
	Variables     map[string]interface{} `json:"variables,omitempty"`

	// Response should be a pointer to a struct to deserialize
	// the JSON response into.
	Response interface{} `json:"-"`

	// URL, if different than client URL (e.g. /graphql)
	URL string `json:"-"`
}

Request holds the parameters for a GraphQL query. Query must be included.

func (*Request) Valid

func (req *Request) Valid() error

Valid checks whether the request has required parameters.

type Response

type Response struct {
	Data   interface{} `json:"data"`
	Errors []Error     `json:"errors"`
}

Response is the response returned from the database for a GraphQL query.

Jump to

Keyboard shortcuts

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