type_system_extension

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 13 Imported by: 0

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 {
	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 MyMutationResolver

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

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()
}

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) 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