inrtospection

package
v0.0.0-llm.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeKindScalar      = TypeKind("SCALAR")
	TypeKindObject      = TypeKind("OBJECT")
	TypeKindInterface   = TypeKind("INTERFACE")
	TypeKindUnion       = TypeKind("UNION")
	TypeKindEnum        = TypeKind("ENUM")
	TypeKindInputObject = TypeKind("INPUT_OBJECT")
	TypeKindList        = TypeKind("LIST")
	TypeKindNonNull     = TypeKind("NON_NULL")
)
View Source
const (
	ScalarInt     = Scalar("Int")
	ScalarFloat   = Scalar("Float")
	ScalarString  = Scalar("String")
	ScalarBoolean = Scalar("Boolean")
	ScalarVoid    = Scalar("Void")
)

Variables

View Source
var Query string

Query is the query generated by graphiql to determine type information

Functions

func ParseGraphQLSchema

func ParseGraphQLSchema(sdl string) map[string]string

Splits a SDL format schema definition and groups it by type name.

Types

type Directive

type Directive struct {
	Name string          `json:"name"`
	Args []*DirectiveArg `json:"args"`
}

func (Directive) Arg

func (t Directive) Arg(name string) *DirectiveArg

func (*Directive) RenderSDL

func (t *Directive) RenderSDL(w io.Writer)

type DirectiveArg

type DirectiveArg struct {
	Name  string  `json:"name"`
	Value *string `json:"value"`
}

type Directives

type Directives []*Directive

func (Directives) Directive

func (t Directives) Directive(name string) *Directive

func (Directives) RenderSDL

func (t Directives) RenderSDL(w io.Writer)

func (*Directives) SourceMap

func (t *Directives) SourceMap() *SourceMap

type EnumValue

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

func (*EnumValue) RenderSDL

func (v *EnumValue) RenderSDL(w io.Writer)

type Field

type Field struct {
	Name              string      `json:"name"`
	Description       string      `json:"description"`
	TypeRef           *TypeRef    `json:"type"`
	Args              InputValues `json:"args"`
	IsDeprecated      bool        `json:"isDeprecated"`
	DeprecationReason string      `json:"deprecationReason"`
	Directives        Directives  `json:"directives"`
}

func (*Field) ReferencesType

func (f *Field) ReferencesType(typeName string) bool

func (*Field) RenderSDL

func (v *Field) RenderSDL(w io.Writer)

type InputValue

type InputValue struct {
	Name         string     `json:"name"`
	Description  string     `json:"description"`
	DefaultValue *string    `json:"defaultValue"`
	TypeRef      *TypeRef   `json:"type"`
	Directives   Directives `json:"directives"`
}

func (InputValue) IsOptional

func (v InputValue) IsOptional() bool

func (InputValue) RenderSDL

func (v InputValue) RenderSDL(w io.Writer)

type InputValues

type InputValues []InputValue

func (InputValues) HasOptionals

func (i InputValues) HasOptionals() bool

type Response

type Response struct {
	Schema        *Schema `json:"__schema"`
	SchemaVersion string  `json:"__schemaVersion"`
}

Response is the introspection query response

type Scalar

type Scalar string

type Schema

type Schema struct {
	QueryType struct {
		Name string `json:"name,omitempty"`
	} `json:"queryType,omitempty"`
	MutationType *struct {
		Name string `json:"name,omitempty"`
	} `json:"mutationType,omitempty"`
	SubscriptionType *struct {
		Name string `json:"name,omitempty"`
	} `json:"subscriptionType,omitempty"`

	Types      Types `json:"types"`
	Directives any   `json:"directives"`
}

func (*Schema) Mutation

func (s *Schema) Mutation() *Type

func (*Schema) OnlyType

func (s *Schema) OnlyType(typeName string)

func (*Schema) Query

func (s *Schema) Query() *Type

func (*Schema) RenderSDL

func (s *Schema) RenderSDL(w io.Writer)

func (*Schema) ScrubType

func (s *Schema) ScrubType(typeName string)

Remove all occurrences of a type from the schema, including any fields, input fields, and enum values that reference it.

func (*Schema) Subscription

func (s *Schema) Subscription() *Type

type SourceMap

type SourceMap struct {
	Module   string
	Filename string
	Line     string
	Column   string
}
func (sourceMap *SourceMap) Filelink() string

type Type

type Type struct {
	Kind        TypeKind     `json:"kind"`
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Fields      []*Field     `json:"fields,omitempty"`
	InputFields []InputValue `json:"inputFields,omitempty"`
	EnumValues  []EnumValue  `json:"enumValues,omitempty"`
	Interfaces  []*Type      `json:"interfaces"`
	Directives  Directives   `json:"directives"`
}

func (*Type) NamedTypes

func (t *Type) NamedTypes(types Types) iter.Seq[*Type]

func (*Type) RenderSDL

func (v *Type) RenderSDL(w io.Writer)

func (*Type) ScrubType

func (t *Type) ScrubType(typeName string) bool

Remove all occurrences of a type from the schema, including any fields, input fields, and enum values that reference it. Returns true if this type should be removed, whether because it is the type being scrubbed, or because it is now empty after scrubbing its references.

type TypeKind

type TypeKind string

type TypeRef

type TypeRef struct {
	Kind   TypeKind `json:"kind"`
	Name   string   `json:"name,omitempty"`
	OfType *TypeRef `json:"ofType,omitempty"`
}

func (TypeRef) IsList

func (r TypeRef) IsList() bool

func (TypeRef) IsObject

func (r TypeRef) IsObject() bool

func (TypeRef) IsOptional

func (r TypeRef) IsOptional() bool

func (TypeRef) IsScalar

func (r TypeRef) IsScalar() bool

func (TypeRef) IsVoid

func (r TypeRef) IsVoid() bool

func (TypeRef) NamedType

func (r TypeRef) NamedType() string

func (TypeRef) ReferencesType

func (r TypeRef) ReferencesType(typeName string) bool

func (TypeRef) String

func (r TypeRef) String() string

type Types

type Types []*Type

func (Types) Get

func (t Types) Get(name string) *Type

Jump to

Keyboard shortcuts

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