introspection

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 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"`
}

Directive represents an instance of the __Directive introspection type: https://spec.graphql.org/October2021/#sec-The-__Directive-Type

type DirectiveLocation

type DirectiveLocation string

DirectiveLocation represents a possible value of the __DirectiveLocation introspection enum.

type EnumValue

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

EnumValue represents an instance of the __EnumValue introspection type: https://spec.graphql.org/October2021/#sec-The-__EnumValue-Type

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"`
}

Field represents an instance of the __Field introspection type: https://spec.graphql.org/October2021/#sec-The-__Field-Type

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"`
}

InputValue represents an instance of the __InputValue introspection type: https://spec.graphql.org/October2021/#sec-The-__InputValue-Type

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"`
}

Schema represents an instance of the __Schema introspection type: https://spec.graphql.org/October2021/#sec-The-__Schema-Type

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 represents an instance of the __Type introspection type: https://spec.graphql.org/October2021/#sec-The-__Type-Type

type TypeKind

type TypeKind string

TypeKind represents a possible value of the __TypeKind introspection enum.

Jump to

Keyboard shortcuts

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