graphql

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 17 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

nautilus/graphql

Build Status Coverage Status Go Report Card

A package that wraps vektah/gqlparser with some convenience methods for building graphql tooling on the server.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntrospectionQuery = `` /* 1141-byte string literal not displayed */

IntrospectionQuery is the query that is fired at an API to reconstruct its schema

Functions

func ApplyFragments

func ApplyFragments(selectionSet ast.SelectionSet, fragmentDefs ast.FragmentDefinitionList) (ast.SelectionSet, error)

ApplyFragments takes a list of selections and merges them into one, embedding any fragments it runs into along the way

func ExtractVariables

func ExtractVariables(args ast.ArgumentList) []string

ExtractVariables takes a list of arguments and returns a list of every variable used

func FormatSelectionSet

func FormatSelectionSet(selection ast.SelectionSet) string

FormatSelectionSet returns a pretty printed version of a selection set

func IntrospectAPI

func IntrospectAPI(queryer Queryer) (*ast.Schema, error)

IntrospectAPI send the introspection query to a Queryer and builds up the schema object described by the result

func LoadSchema

func LoadSchema(typedef string) (*ast.Schema, error)

LoadSchema takes an SDL string and returns the parsed version

func PrintQuery

func PrintQuery(document *ast.QueryDocument) (string, error)

PrintQuery creates a string representation of an operation

func SelectedFields

func SelectedFields(source ast.SelectionSet) []*ast.Field

Types

type CollectedField

type CollectedField struct {
	*ast.Field
	NestedSelections []ast.SelectionSet
}

CollectedField is a representations of a field with the list of selection sets that must be merged under that field.

type CollectedFieldList

type CollectedFieldList []*CollectedField

CollectedFieldList is a list of CollectedField with utilities for retrieving them

func (*CollectedFieldList) GetOrCreateForAlias

func (c *CollectedFieldList) GetOrCreateForAlias(alias string, creator func() *CollectedField) *CollectedField

type Error

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

Error represents a graphql error

func NewError

func NewError(code string, message string) *Error

NewError returns a graphql error with the given code and message

func (*Error) Error

func (e *Error) Error() string

type ErrorList

type ErrorList []error

ErrorList represents a list of errors

func (ErrorList) Error

func (list ErrorList) Error() string

Error returns a string representation of each error

type HTTPQueryer

type HTTPQueryer interface {
	WithHTTPClient(client *http.Client) Queryer
}

HTTPQueryer is an interface for queryers that let you configure an underlying http.Client

type HTTPQueryerWithMiddlewares

type HTTPQueryerWithMiddlewares interface {
	WithHTTPClient(client *http.Client) Queryer
	WithMiddlewares(wares []NetworkMiddleware) Queryer
}

HTTPQueryerWithMiddlewares is an interface for queryers that let you configure an underlying http.Client and accept middlewares

type IntrospectionInputValue

type IntrospectionInputValue struct {
	Name         string               `json:"name"`
	Description  string               `json:"description"`
	DefaultValue string               `json:"defaultValue"`
	Type         IntrospectionTypeRef `json:"type"`
}

type IntrospectionQueryDirective

type IntrospectionQueryDirective struct {
	Name        string                    `json:"name"`
	Description string                    `json:"description"`
	Locations   []string                  `json:"locations"`
	Args        []IntrospectionInputValue `json:"arg"`
}

type IntrospectionQueryEnumDefinition

type IntrospectionQueryEnumDefinition struct {
	Name              string `json:"name"`
	Description       string `json:"description"`
	IsDeprecated      bool   `json:"isDeprecated"`
	DeprecationReason string `json:"deprecationReason"`
}

type IntrospectionQueryFullType

type IntrospectionQueryFullType struct {
	Kind          string                             `json:"kind"`
	Name          string                             `json:"name"`
	Description   string                             `json:"description"`
	InputFields   []IntrospectionInputValue          `json:"inputFields"`
	Interfaces    []IntrospectionTypeRef             `json:"interfaces"`
	PossibleTypes []IntrospectionTypeRef             `json:"possibleTypes"`
	Fields        []IntrospectionQueryFullTypeField  `json:"fields"`
	EnumValues    []IntrospectionQueryEnumDefinition `json:"enumValues"`
}

type IntrospectionQueryFullTypeField

type IntrospectionQueryFullTypeField struct {
	Name              string                    `json:"name"`
	Description       string                    `json:"description"`
	Args              []IntrospectionInputValue `json:"args"`
	Type              IntrospectionTypeRef      `json:"type"`
	IsDeprecated      bool                      `json:"isDeprecated"`
	DeprecationReason string                    `json:"deprecationReason"`
}

type IntrospectionQueryResult

type IntrospectionQueryResult struct {
	Schema *IntrospectionQuerySchema `json:"__schema"`
}

type IntrospectionQueryRootType

type IntrospectionQueryRootType struct {
	Name string `json:"name"`
}

type IntrospectionQuerySchema

type IntrospectionQuerySchema struct {
	QueryType        IntrospectionQueryRootType    `json:"queryType"`
	MutationType     *IntrospectionQueryRootType   `json:"mutationType"`
	SubscriptionType *IntrospectionQueryRootType   `json:"subscriptionType"`
	Types            []IntrospectionQueryFullType  `json:"types"`
	Directives       []IntrospectionQueryDirective `json:"directives"`
}

type IntrospectionTypeRef

type IntrospectionTypeRef struct {
	Kind   string                `json:"kind"`
	Name   string                `json:"name"`
	OfType *IntrospectionTypeRef `json:"ofType"`
}

type MockSuccessQueryer

type MockSuccessQueryer struct {
	Value interface{}
}

MockSuccessQueryer responds with pre-defined value when executing a query

func (*MockSuccessQueryer) Query

func (q *MockSuccessQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error

Query looks up the name of the query in the map of responses and returns the value

type MultiOpQueryer

type MultiOpQueryer struct {
	MaxBatchSize  int
	BatchInterval time.Duration
	// contains filtered or unexported fields
}

MultiOpQueryer is a queryer that will batch subsequent query on some interval into a single network request to a single target

func NewMultiOpQueryer

func NewMultiOpQueryer(url string, interval time.Duration, maxBatchSize int) *MultiOpQueryer

NewMultiOpQueryer returns a MultiOpQueryer with the provided paramters

func (*MultiOpQueryer) Query

func (q *MultiOpQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error

Query bundles queries that happen within the given interval into a single network request whose body is a list of the operation payload.

func (*MultiOpQueryer) WithHTTPClient

func (q *MultiOpQueryer) WithHTTPClient(client *http.Client) Queryer

WithHTTPClient lets the user configure the client to use when making network requests

func (*MultiOpQueryer) WithMiddlewares

func (q *MultiOpQueryer) WithMiddlewares(mwares []NetworkMiddleware) Queryer

WithMiddlewares lets the user assign middlewares to the queryer

type NetworkMiddleware

type NetworkMiddleware func(*http.Request) error

NetworkMiddleware are functions can be passed to SingleRequestQueryer.WithMiddleware to affect its internal behavior

type NetworkQueryer

type NetworkQueryer struct {
	AuthToken   string
	URL         string
	Middlewares []NetworkMiddleware
	Client      *http.Client
}

func (*NetworkQueryer) ExtractErrors

func (q *NetworkQueryer) ExtractErrors(result map[string]interface{}) error

ExtractErrors takes the result from a remote query and writes it to the provided pointer

func (*NetworkQueryer) SendQuery

func (q *NetworkQueryer) SendQuery(ctx context.Context, payload []byte) ([]byte, error)

SendQuery is responsible for sending the provided payload to the desingated URL

func (*NetworkQueryer) SendQueryWithAuth

func (q *NetworkQueryer) SendQueryWithAuth(ctx context.Context, auth string, payload []byte) ([]byte, error)

SendQueryWithAuth is responsible for sending the provided payload to the designated URL

type QueryInput

type QueryInput struct {
	Query         string                 `json:"query"`
	QueryDocument *ast.QueryDocument     `json:"-"`
	OperationName string                 `json:"operationName"`
	Variables     map[string]interface{} `json:"variables"`
}

QueryInput provides all of the information required to fire a query

func (*QueryInput) Raw

func (i *QueryInput) Raw() interface{}

Raw returns the "raw underlying value of the key" when used by dataloader

func (*QueryInput) String

func (i *QueryInput) String() string

String returns a guarenteed unique string that can be used to identify the input

type Queryer

type Queryer interface {
	Query(context.Context, *QueryInput, interface{}) error
}

Queryer is a interface for objects that can perform

type QueryerFunc

type QueryerFunc func(*QueryInput) (interface{}, error)

QueryerFunc responds to the query by calling the provided function

func (QueryerFunc) Query

func (q QueryerFunc) Query(ctx context.Context, input *QueryInput, receiver interface{}) error

Query invokes the provided function and writes the response to the receiver

type QueryerWithMiddlewares

type QueryerWithMiddlewares interface {
	WithMiddlewares(wares []NetworkMiddleware) Queryer
}

QueryerWithMiddlewares is an interface for queryers that support network middlewares

type RemoteSchema

type RemoteSchema struct {
	Schema *ast.Schema
	URL    string
}

RemoteSchema encapsulates a particular schema that can be executed by sending network requests to the specified URL.

func IntrospectRemoteSchema

func IntrospectRemoteSchema(url string) (*RemoteSchema, error)

IntrospectRemoteSchema is used to build a RemoteSchema by firing the introspection query at a remote service and reconstructing the schema object from the response

func IntrospectRemoteSchemaWithAuth

func IntrospectRemoteSchemaWithAuth(url, auth string) (*RemoteSchema, error)

IntrospectRemoteSchemaWithAuth is used to build a RemoteSchema by firing the introspection query at a remote service and reconstructing the schema object from the response

func IntrospectRemoteSchemas

func IntrospectRemoteSchemas(urls ...string) ([]*RemoteSchema, error)

IntrospectRemoteSchemas takes a list of URLs and creates a RemoteSchema by invoking graphql.IntrospectRemoteSchema at that location.

func IntrospectRemoteSchemasWithAuth

func IntrospectRemoteSchemasWithAuth(urls map[string]string) ([]*RemoteSchema, error)

IntrospectRemoteSchemasWithAuth takes a list of URLs and creates a RemoteSchema by invoking graphql.IntrospectRemoteSchema at that location.

type SingleRequestQueryer

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

SingleRequestQueryer sends the query to a url and returns the response

func NewSingleRequestQueryer

func NewSingleRequestQueryer(url string) *SingleRequestQueryer

NewSingleRequestQueryer returns a SingleRequestQueryer pointed to the given url

func NewSingleRequestQueryerWithAuth

func NewSingleRequestQueryerWithAuth(auth, url string) *SingleRequestQueryer

NewSingleRequestQueryerWithAuth returns a SingleRequestQueryer pointed to the given url

func (*SingleRequestQueryer) AuthToken

func (q *SingleRequestQueryer) AuthToken() string

func (*SingleRequestQueryer) Query

func (q *SingleRequestQueryer) Query(ctx context.Context, input *QueryInput, receiver interface{}) error

Query sends the query to the designated url and returns the response.

func (*SingleRequestQueryer) URL

func (q *SingleRequestQueryer) URL() string

func (*SingleRequestQueryer) WithHTTPClient

func (q *SingleRequestQueryer) WithHTTPClient(client *http.Client) Queryer

WithHTTPClient lets the user configure the underlying http client being used

func (*SingleRequestQueryer) WithMiddlewares

func (q *SingleRequestQueryer) WithMiddlewares(mwares []NetworkMiddleware) Queryer

WithMiddlewares returns a network queryer that will apply the provided middlewares

Jump to

Keyboard shortcuts

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