router

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 20 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

	// Vertex is a recorder for sending logs to the request's vertex in the
	// progress stream.
	Vertex *progrock.VertexRecorder
}

type Digestible added in v0.5.2

type Digestible interface {
	Digest() (digest.Digest, error)
}

Digestible is any object which can return a digest of its content.

It is used to record the request's result as an output of the request's vertex in the progress stream.

type DirectConn added in v0.5.3

type DirectConn func(*http.Request) (*http.Response, error)

func EngineConn added in v0.5.3

func EngineConn(r *Router) DirectConn

func (DirectConn) Close added in v0.5.3

func (f DirectConn) Close() error

func (DirectConn) Do added in v0.5.3

func (f DirectConn) Do(r *http.Request) (*http.Response, error)

func (DirectConn) Host added in v0.5.3

func (f DirectConn) Host() string

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 Pipelineable added in v0.5.2

type Pipelineable interface {
	PipelinePath() pipeline.Path
}

Pipelineable is any object which can return a pipeline.Path.

It is used to construct a Progrock recorder group that is passed via ctx to the resolver.

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, recorder *progrock.Recorder) *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) 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 🇻🇳