introspection

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package introspection adds very basic remote GraphQL introspection funcionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg struct {
	// Name is a schema defined argument name
	Name string `json:"name,omitempty"`
	// Description is a schema defined argument description
	Description string `json:"description,omitempty"`
	// Type is a type or type reference defined by schema
	Type         Type   `json:"type,omitempty"`
	DefaultValue string `json:"defaultValue,omitempty"`
}

Arg is graphql field argument

func (Arg) GoString

func (a Arg) GoString() string

GoString formats argument as it would apear in schema

type Field

type Field struct {
	// Args is a list of arguments for a field defined by schema
	Args []Arg `json:"args,omitempty"`
	// Name is a field name defined by schema
	Name string `json:"name,omitempty"`
	// Type is a type or type reference defined by schema
	Type Type `json:"type,omitempty"`
	// Description is a schema defined argument description
	Description string `json:"description,omitempty"`
}

Field is graphql field

func (Field) ArgNames

func (f Field) ArgNames() []string

ArgNames is an array of arguments that this field accepts

func (Field) ArgsString

func (f Field) ArgsString() string

ArgsString formats field arguments as they would apear in schema

func (Field) GoString

func (f Field) GoString() string

GoString formats field as it would apear in schema

type Schema

type Schema struct {
	// Types defined in schema
	Types []Type `json:"types,omitempty"`
	// QueryType is a reference to a type of query root operation
	QueryType Type `json:"queryType"`
	// MutationType is a reference to a type of mutation root operation
	MutationType Type `json:"mutationType,omitempty"`
	// SubscriptionType is a reference to a type of subscription root operation
	SubscriptionType Type `json:"subscriptionType,omitempty"`
}

Schema is a representation of remote schema returned by schema introspection

func GetSchemaTypes

func GetSchemaTypes(cli *client.Client, header http.Header) (Schema, error)

GetSchemaTypes runs introspection query on remote endpoint returning schema

func (Schema) FieldForPath

func (s Schema) FieldForPath(path []string) (f Field, ok bool)

FieldForPath finds a field to which path would resolve to

func (Schema) TypeForPath

func (s Schema) TypeForPath(path []string) (t Type, ok bool)

TypeForPath finds a type to which path would resolve to

type Type

type Type struct {
	// Name is a type or type reference name
	Name string `json:"name,omitempty"`
	// Fields is a list of fields for this type, defined by schema
	// Object and Interface only
	Fields []Field `json:"fields,omitempty"`
	// Kind is a type kind, refer to https://godoc.org/github.com/graphql-go/graphql#pkg-constants
	// for valid list of type kinds
	Kind string `json:"kind,omitempty"`
	// Description is a schema defined argument description
	Description string `json:"description,omitempty"`
	// PossibleTypes is a list of possible types defined by schema
	// only valid for Union and Interface kidns
	PossibleTypes []Type `json:"possibleTypes,omitempty"`
	// OfType is a type reference which this type wraps
	// only valid for NonNull and List type kinds
	OfType *Type `json:"ofType,omitempty"`
}

Type is graphql type definition

func GetTypeInfo

func GetTypeInfo(cli *client.Client, typeName string, header http.Header) (Type, error)

GetTypeInfo fetches type information from remote endpoint

func (Type) Deref

func (t Type) Deref(types []Type) Type

Deref finds a type matching this type reference in a list of types

func (Type) Enum

func (t Type) Enum() bool

Enum returns true if type is an Enum

func (Type) GetOfTypeLeaf

func (t Type) GetOfTypeLeaf() Type

GetOfTypeLeaf follows solves all NonNull/List types until it reaches named type

func (Type) GoString

func (t Type) GoString() string

GoString formats type to a string as it would appear in schema

func (Type) Input

func (t Type) Input() bool

Input returns true if type is an Input

func (Type) Interface

func (t Type) Interface() bool

Interface returns true if type is an Interface

func (Type) List

func (t Type) List() bool

List returns true if type is a List

func (Type) Named

func (t Type) Named() bool

Named returns true if type is named, as in, not NonNull or List

func (Type) NonNull

func (t Type) NonNull() bool

NonNull returns true if type is NonNull

func (Type) Object

func (t Type) Object() bool

Object returns true if type is an Object

func (Type) Scalar

func (t Type) Scalar() bool

Scalar returns true if type is of scalar type

func (Type) TypeForPath

func (t Type) TypeForPath(schema Schema, path []string) (tt Type, ok bool)

TypeForPath seeks a type in schema matching resolve path. First element of path must match one of type fields

func (Type) TypeRef

func (t Type) TypeRef() bool

TypeRef returns true if type is a type reference

func (Type) Union

func (t Type) Union() bool

Union returns true type is an Union

func (Type) Valid

func (t Type) Valid() bool

Valid returns true if type is valid type

Jump to

Keyboard shortcuts

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