type_system_extension

package
v0.0.0-...-ecc3f64 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 14 Imported by: 1

README

Type System Extension example

https://graphql.github.io/graphql-spec/draft/#sec-Type-System-Extensions

$ go run ./server/server.go
2018/10/25 12:46:45 connect to http://localhost:8080/ for GraphQL playground

$ curl -X POST 'http://localhost:8080/query' --data-binary '{"query":"{ todos { id text state verified } }"}'
{"data":{"todos":[{"id":"Todo:1","text":"Buy a cat food","state":"NOT_YET","verified":false},{"id":"Todo:2","text":"Check cat water","state":"DONE","verified":true},{"id":"Todo:3","text":"Check cat meal","state":"DONE","verified":true}]}}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllState = []State{
	StateNotYet,
	StateDone,
}

Functions

func EnumLogging

func EnumLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

func FieldLogging

func FieldLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

func InputLogging

func InputLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func ObjectLogging

func ObjectLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

func ScalarLogging

func ScalarLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

func UnionLogging

func UnionLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)

Types

type ComplexityRoot

type ComplexityRoot struct {
	MyMutation struct {
		CreateTodo func(childComplexity int, todo TodoInput) int
	}

	MyQuery struct {
		Todo  func(childComplexity int, id string) int
		Todos func(childComplexity int) int
	}

	Todo struct {
		ID       func(childComplexity int) int
		State    func(childComplexity int) int
		Text     func(childComplexity int) int
		Verified func(childComplexity int) int
	}
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type Data

type Data interface {
	IsData()
}

type DirectiveRoot

type DirectiveRoot struct {
	EnumLogging      func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	FieldLogging     func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	InputLogging     func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	ObjectLogging    func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	ScalarLogging    func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
	UnionLogging     func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error)
}

type MyMutation

type MyMutation struct {
}

type MyMutationResolver

type MyMutationResolver interface {
	CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error)
}

type MyQuery

type MyQuery struct {
}

type MyQueryResolver

type MyQueryResolver interface {
	Todos(ctx context.Context) ([]*Todo, error)
	Todo(ctx context.Context, id string) (*Todo, error)
}

type Node

type Node interface {
	IsNode()
	GetID() string
}

type ResolverRoot

type ResolverRoot interface {
	MyMutation() MyMutationResolver
	MyQuery() MyQueryResolver
}

func NewRootResolver

func NewRootResolver() ResolverRoot

type State

type State string
const (
	StateNotYet State = "NOT_YET"
	StateDone   State = "DONE"
)

func (State) IsValid

func (e State) IsValid() bool

func (State) MarshalGQL

func (e State) MarshalGQL(w io.Writer)

func (State) String

func (e State) String() string

func (*State) UnmarshalGQL

func (e *State) UnmarshalGQL(v interface{}) error

type Todo

type Todo struct {
	ID       string `json:"id"`
	Text     string `json:"text"`
	State    State  `json:"state"`
	Verified bool   `json:"verified"`
}

func (Todo) GetID

func (this Todo) GetID() string

func (Todo) IsData

func (Todo) IsData()

func (Todo) IsNode

func (Todo) IsNode()

type TodoInput

type TodoInput struct {
	Text string `json:"text"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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