graphql

package
v0.0.0-...-0edac8c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package graphql contains a graphql client which talks to a MongoDB Realm GraphQL Server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a Realm GraphQL Client with authentication to a Realm Application. The Realm GraphQL Server URI is stored in uri

func NewClient

func NewClient(opts *options.ClientOptions) (*Client, error)

NewClient creates a new Client

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes Realm auth and creates a new graphql client

func (*Client) Health

func (c *Client) Health(response *Response) error

Health needs to be implemented on the GraphQL Server as it looks for a very specific schema/document.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, mutation string, variables map[string]interface{}, response *Response) error

Mutate wrapper

func (*Client) Query

func (c *Client) Query(ctx context.Context, query interface{}, variables map[string]interface{}, response *Response) error

Query wrapper

type Error

type Error struct {
	Message    string                 `json:"message,omitempty"`
	Path       PathSegment            `json:"path,omitempty"`
	Locations  []Location             `json:"locations,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

Error is a GraphQL Error as per http://spec.graphql.org/June2018/#sec-Errors

type HealthCheck

type HealthCheck struct {
	ID          string
	Description string
	Status      string
	Endpoint    string
}

HealthCheck Query for Realm Config Verification

type Location

type Location struct {
	Line   int `json:"line,omitempty"`
	Column int `json:"column,omitempty"`
}

Location returned when the response had an error. Each location is a map with the keys line and column, both positive numbers starting from 1 which describe the beginning of an associated syntax element

type PathSegment

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

PathSegment returned when the response had an error. Path segments that represent fields should be strings, and path segments that represent list indices should be 0‐indexed integers. If the error happens in an aliased field, the path to the error should use the aliased name, since it represents a path in the response, not in the query.

type Request

type Request struct {
	Query         string   `json:"query" graphql:"query"`
	Variables     Variable `json:"variables" graphql:"variables"`
	OperationName *string  `json:"operationName" graphql:"operationName"`
}

Request is the payload for GraphQL

type Response

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

Response is the payload for a GraphQL response.

type Variable

type Variable map[string]interface{}

Variable is a GraphQL Variable passed in the Body of a GraphQL Request.

Jump to

Keyboard shortcuts

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