model

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: 7 Imported by: 0

Documentation

Index

Constants

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

See __TypeKind in the spec: https://spec.graphql.org/October2021/#sel-GAJXNFAD7EAADxFAB45Y

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

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

type ArgumentDefinition added in v0.1.8

type ArgumentDefinition struct {
	Name         string
	Description  string
	DefaultValue Value
	Type         *Type
	Directives   DirectiveList
}

Based on the __InputValue introspection type.

func (*ArgumentDefinition) MarshalJSON added in v0.1.8

func (a *ArgumentDefinition) MarshalJSON() ([]byte, error)

type ArgumentDefinitionList added in v0.1.8

type ArgumentDefinitionList []*ArgumentDefinition

type ArgumentList

type ArgumentList []*Argument

type Definition

type Definition struct {
	Kind        ast.DefinitionKind
	Name        string
	Description string
	Directives  DirectiveList

	// only set for interfaces, objects, input objects
	Fields FieldDefinitionList

	// only set for interfaces
	Interfaces []string

	// only set for interfaces & unions
	PossibleTypes []string

	// only set for enums
	EnumValues EnumValueList
}

Based on the __Type introspection type: https://spec.graphql.org/October2021/#sec-The-__Type-Type

func (*Definition) MarshalJSON added in v0.1.8

func (d *Definition) MarshalJSON() ([]byte, error)

func (*Definition) String

func (d *Definition) String() string

type DefinitionList

type DefinitionList []*Definition

func (DefinitionList) Sort added in v0.1.9

func (d DefinitionList) Sort()

func (DefinitionList) ToMap added in v0.1.9

func (d DefinitionList) ToMap() DefinitionMap

type DefinitionMap added in v0.1.9

type DefinitionMap map[string]*Definition

func MakeDefinitionMap added in v0.1.9

func MakeDefinitionMap(in DefinitionList) DefinitionMap

func (DefinitionMap) ToSortedList added in v0.1.9

func (d DefinitionMap) ToSortedList() DefinitionList

type Directive

type Directive struct {
	Name      string       `json:"name"`
	Arguments ArgumentList `json:"arguments,omitempty"`
}

Directive represents a specific application site / instantiation of a directive.

Note that this type does *not* appear in the GraphQL introspection schema, which lacks information about most directive application sites (with the exception of @deprecated, which is special-cased).

type DirectiveDefinition

type DirectiveDefinition struct {
	Description  string                  `json:"description"`
	Name         string                  `json:"name"`
	Arguments    ArgumentDefinitionList  `json:"arguments,omitempty"`
	Locations    []ast.DirectiveLocation `json:"locations"`
	IsRepeatable bool                    `json:"repeatable"`
}

DirectiveDefinition represents the definition of a directive. Based on the __Directive introspection type defined here: https://spec.graphql.org/October2021/#sec-The-__Directive-Type

type DirectiveDefinitionList

type DirectiveDefinitionList []*DirectiveDefinition

DirectiveDefinitionList represents a list of directive definitions.

type DirectiveList

type DirectiveList []*Directive

DirectiveList represents a list of directives all applied at the same application site.

type EnumValueDefinition

type EnumValueDefinition struct {
	Description string        `json:"description,omitempty"`
	Name        string        `json:"name"`
	Directives  DirectiveList `json:"directives,omitempty"`
}

EnumValueDefinition represents a single possible value for a GraphQL enum. Based on the __EnumValue introspection type specified here: https://spec.graphql.org/October2021/#sec-The-__EnumValue-Type Note that the isDeprecated and deprecationReason fields are replaced by the more generic 'directives' field.

type EnumValueList

type EnumValueList []*EnumValueDefinition

EnumValueList represents a set of possible enum values for a single enum.

type FieldDefinition

type FieldDefinition struct {
	Name         string                 `json:"name"`
	Description  string                 `json:"description,omitempty"`
	Type         *Type                  `json:"type"`
	Arguments    ArgumentDefinitionList `json:"arguments,omitempty"`    // only for fields
	DefaultValue Value                  `json:"defaultValue,omitempty"` // only for input values
	Directives   DirectiveList          `json:"directives,omitempty"`
}

Based on the __Field and __InputValue introspection types: https://spec.graphql.org/October2021/#sec-The-__Field-Type

Notable differences from the spec:

  • __Field and __InputValue are represented here by a single merged type, where some fields are left blank when not applicable.
  • The directives field represents information about directives attached to a given field or input value, which is not present in the introspection schema.
  • As a result of the above, the deprecated and deprecationReason fields are omitted, since they would duplicate the content of the more generic directives field.

func (*FieldDefinition) MarshalJSON

func (fd *FieldDefinition) MarshalJSON() ([]byte, error)

type FieldDefinitionList

type FieldDefinitionList []*FieldDefinition

FieldDefinitionList represents a set of fields definitions on the same object, interface, or input type.

func (FieldDefinitionList) Named added in v0.2.2

func (fdl FieldDefinitionList) Named(name string) *FieldDefinition

func (FieldDefinitionList) Sort added in v0.1.9

func (fdl FieldDefinitionList) Sort()

type NameReference

type NameReference struct {
	TypeName  string
	FieldName string
}

func FieldNameReference

func FieldNameReference(typeName, fieldName string) NameReference

func TypeNameReference

func TypeNameReference(name string) NameReference

type Schema

type Schema struct {
	Description          string
	Types                DefinitionMap
	QueryTypeName        string
	MutationTypeName     string
	SubscriptionTypeName string
	Directives           DirectiveDefinitionList
}

Based on the __Schema introspection type: https://spec.graphql.org/October2021/#sec-The-__Schema-Type

The QueryType, MutationType, and SubscriptionType fields have been suffixed with 'Name' and are represented as strings referring to named types, rather than nested objects.

func MakeSchema

func MakeSchema(in *ast.Schema) (*Schema, error)

MakeSchema constructs and returns a Schema from the given ast.Schema. The provided ast.Schema must be 'complete' in the sense that it must contain type definitions for all types used in the schema, including built-in types like String, Int, etc.

func (*Schema) FilterBuiltins

func (s *Schema) FilterBuiltins()

func (*Schema) MarshalJSON added in v0.1.9

func (s *Schema) MarshalJSON() ([]byte, error)

func (*Schema) ResolveNames

func (s *Schema) ResolveNames(names []string) ([]*NameReference, error)

type Type

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

func (*Type) String

func (t *Type) String() string

func (*Type) Unwrap

func (t *Type) Unwrap() *Type

type TypeKind

type TypeKind string

type Value

type Value any

Jump to

Keyboard shortcuts

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