gql

package
v0.0.0-...-7aeffd2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorPresenter = func(logger *slog.Logger) graphql.ErrorPresenterFunc {
	return func(ctx context.Context, err error) *gqlerror.Error {
		if err == nil {
			return &errInternalServer
		}

		logger.Info("api error", slog.String("original_error", err.Error()))

		apiErr := parseError(ctx, err)

		apiErr.Path = graphql.GetPath(ctx)

		return &apiErr
	}
}

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Foo struct {
		ID func(childComplexity int) int
	}

	Mutation struct {
		CreateFoo func(childComplexity int, id string) int
	}

	Query struct {
		GetFoo func(childComplexity int, id string) int
	}
}

type Config

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

type DirectiveRoot

type DirectiveRoot struct {
}

type MutationResolver

type MutationResolver interface {
	CreateFoo(ctx context.Context, id string) (*model.Foo, error)
}

type QueryResolver

type QueryResolver interface {
	GetFoo(ctx context.Context, id string) (*model.Foo, error)
}

type Resolver

type Resolver struct {
	FooService fooService
	// contains filtered or unexported fields
}

Resolver is the root resolver for the GraphQL API it contains all the services that will be used by the resolvers.

func NewResolvers

func NewResolvers(logger *slog.Logger, fooService fooService) *Resolver

NewResolvers returns a new instance of the root resolver.

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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