introspection

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScalarKind      = TypeKind("SCALAR")
	ObjectKind      = TypeKind("OBJECT")
	InterfaceKind   = TypeKind("INTERFACE")
	UnionKind       = TypeKind("UNION")
	EnumKind        = TypeKind("ENUM")
	InputObjectKind = TypeKind("INPUT_OBJECT")
	ListKind        = TypeKind("LIST")
	NonNullKind     = TypeKind("NON_NULL")
)

Variables

This section is empty.

Functions

func GetQuery

func GetQuery(sv SpecVersion) string

GetQuery returns a GraphQL introspection query that is compatible with the given version of the GraphQL spec.

Types

type Client

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

Client is a client capable of issuing an introspection query against a GraphQL server over HTTP, and transforming the response into either an *ast.Schema.

func NewClient

func NewClient(endpoint string, headers http.Header, specVersion SpecVersion, traceOut io.Writer) *Client

NewClient returns a new GraphQL introspection client. HTTP requests issued by this client will use the given HTTP headers, in addition to some defaults. The given SpecVersion will be used to ensure that the introspection query issued by the client is compatible with a specific version of the GraphQL spec. If traceOut is non-nil, the outbound request and returned response will be dumped to it for debugging purposes.

func (*Client) FetchSchemaAst

func (c *Client) FetchSchemaAst() (*ast.Schema, error)

type Directive

type Directive struct {
	Name         string              `json:"name"`
	Description  string              `json:"description,omitempty"`
	Locations    []DirectiveLocation `json:"locations"`
	Args         []InputValue        `json:"args"`
	IsRepeatable bool                `json:"isRepeatable"`
}

type DirectiveLocation

type DirectiveLocation string

type EnumValue

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

type Field

type Field struct {
	Name              string       `json:"name"`
	Description       string       `json:"description,omitempty"`
	Args              []InputValue `json:"args,omitempty"`
	Type              *Type        `json:"type"`
	IsDeprecated      bool         `json:"isDeprecated"`
	DeprecationReason string       `json:"deprecationReason"`
}

type GraphQLParams

type GraphQLParams struct {
	Query         string         `json:"query"`
	OperationName string         `json:"operationName"`
	Variables     map[string]any `json:"variables"`
}

type InputValue

type InputValue struct {
	Name         string  `json:"name"`
	Description  string  `json:"description,omitempty"`
	Type         *Type   `json:"type"`
	DefaultValue *string `json:"defaultValue,omitempty"`
}

type IntrospectionQueryResult

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

type Schema

type Schema struct {
	Types            []Type      `json:"types"`
	QueryType        Type        `json:"queryType,omitempty"`
	MutationType     Type        `json:"mutationType,omitempty"`
	SubscriptionType Type        `json:"subscriptionType,omitempty"`
	Directives       []Directive `json:"directives,omitempty"`
}

type SpecVersion

type SpecVersion struct {
	HasSpecifiedByURL    bool
	HasIsRepeatable      bool
	HasSchemaDescription bool
	// contains filtered or unexported fields
}

SpecVersion represents a version of the GraphQL specification. Versions are listed at https://spec.graphql.org/

func ParseSpecVersion

func ParseSpecVersion(raw string) (SpecVersion, error)

type Type

type Type struct {
	Kind        TypeKind `json:"kind"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`

	// OBJECT and INTERFACE only
	Fields []Field `json:"fields,omitempty"`

	// OBJECT only
	Interfaces []Type `json:"interfaces,omitempty"`

	// INTERFACE and UNION only
	PossibleTypes []Type `json:"possibleTypes,omitempty"`

	// ENUM only
	EnumValues []EnumValue `json:"enumValues,omitempty"`

	// INPUT_OBJECT only
	InputFields []InputValue `json:"inputFields,omitempty"`

	// NON_NULL and LIST only
	OfType *Type `json:"ofType,omitempty"`
}

type TypeKind

type TypeKind string

Jump to

Keyboard shortcuts

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