router

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMergeTypeConflict   = errors.New("object type re-defined")
	ErrMergeFieldConflict  = errors.New("field re-defined")
	ErrMergeScalarConflict = errors.New("scalar re-defined")
)

Functions

func ErrResolver

func ErrResolver(err error) graphql.FieldResolveFn

func PassthroughResolver

func PassthroughResolver(p graphql.ResolveParams) (any, error)

func ToResolver

func ToResolver[P any, A any, R any](f func(*Context, P, A) (R, error)) graphql.FieldResolveFn

ToResolver transforms any function f with a *Context, a parent P and some args A that returns a Response R and an error into a graphql resolver graphql.FieldResolveFn.

Types

type Context

type Context struct {
	context.Context
	ResolveParams graphql.ResolveParams
}

type ExecutableSchema

type ExecutableSchema interface {
	LoadedSchema
	Resolvers() Resolvers
	Dependencies() []ExecutableSchema
}

func MergeExecutableSchemas

func MergeExecutableSchemas(name string, schemas ...ExecutableSchema) (ExecutableSchema, error)

type InvalidInputError added in v0.3.3

type InvalidInputError struct {
	Err error
}

func (InvalidInputError) Error added in v0.3.3

func (e InvalidInputError) Error() string

func (InvalidInputError) Unwrap added in v0.3.3

func (e InvalidInputError) Unwrap() error

type LoadedSchema

type LoadedSchema interface {
	Name() string
	Schema() string
}

func MergeLoadedSchemas

func MergeLoadedSchemas(name string, schemas ...LoadedSchema) LoadedSchema

type ObjectResolver

type ObjectResolver map[string]graphql.FieldResolveFn

type Resolver

type Resolver interface {
	// contains filtered or unexported methods
}

type Resolvers

type Resolvers map[string]Resolver

type Router

type Router struct {
	// contains filtered or unexported fields
}

func New

func New(sessionToken string) *Router

func (*Router) Add

func (r *Router) Add(schema ExecutableSchema) error

func (*Router) Do

func (r *Router) Do(ctx context.Context, query string, opName string, variables map[string]any, data any) (*graphql.Result, error)

Do executes a query directly in the server

func (*Router) Get

func (r *Router) Get(name string) ExecutableSchema

func (*Router) ServeConn

func (r *Router) ServeConn(conn net.Conn) error

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

type ScalarResolver

type ScalarResolver struct {
	Serialize    graphql.SerializeFn
	ParseValue   graphql.ParseValueFn
	ParseLiteral graphql.ParseLiteralFn
}

type StaticSchemaParams

type StaticSchemaParams struct {
	Name         string
	Schema       string
	Resolvers    Resolvers
	Dependencies []ExecutableSchema
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳