graphql

package module
v0.0.0-...-807967d Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 23 Imported by: 0

README

graphql

GraphQL module of the Modulus Framework based on https://gqlgen.com

Documentation

Index

Constants

View Source
const (
	LoadersKey contextKey = "Loaders"
)

Variables

This section is empty.

Functions

func GetLoader

func GetLoader[K comparable, T any](ctx context.Context, factory LoaderFactory[K, T]) *dataloader.Loader[K, T]

func NewGraphqlServer

func NewGraphqlServer(
	params ServerParams,
) *handler.Server

func NewHandlerRoute

func NewHandlerRoute(handler *handler.Server, config Config) (modulusHttp.RouteProvider, modulusHttp.RouteProvider)

func NewManifesto

func NewManifesto() module.Manifesto

NewManifestModule creates a new graphql module with the manifest module.

func NewModule

func NewModule(options ...module.Option) *module.Module

func NewPlaygroundHandlerRoute

func NewPlaygroundHandlerRoute(config Config) modulusHttp.RouteProvider

func OverrideErrorPresenter

func OverrideErrorPresenter[T ErrorPresenterFactory](gqlModule *module.Module) *module.Module

OverrideErrorPresenter overrides the error presenter provider.

func WithLoaders

func WithLoaders(ctx context.Context, loaders *sync.Map) context.Context

Types

type Config

type Config struct {
	ComplexityLimit      int    `env:"GQL_COMPLEXITY_LIMIT, default=200"`
	Path                 string `env:"GQL_API_URL, default=/graphql"`
	IntrospectionEnabled bool   `env:"GQL_INTROSPECTION_ENABLED, default=true"`
	TracingEnabled       bool   `env:"GQL_TRACING_ENABLED, default=false"`
	ReturnCause          bool   `env:"GQL_RETURN_CAUSE, default=false"`
	Playground           PlaygroundConfig
}

type ErrorPresenterFactory

type ErrorPresenterFactory interface {
	NewErrorPresenter() graphql.ErrorPresenterFunc
}

type ErrorPresenterParams

type ErrorPresenterParams struct {
	fx.In

	ErrorPipeline *errhttp.ErrorPipeline `optional:"true"`
	Config        Config
}

type LoaderFactory

type LoaderFactory[K comparable, T any] interface {
	Create() *dataloader.Loader[K, T]
}

type LoadersInitializer

type LoadersInitializer struct{}

func NewLoadersInitializer

func NewLoadersInitializer() *LoadersInitializer

func (LoadersInitializer) ExtensionName

func (LoadersInitializer) ExtensionName() string

func (LoadersInitializer) InterceptOperation

InterceptOperation Init loaders before each operation

func (LoadersInitializer) InterceptResponse

func (l LoadersInitializer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response

InterceptResponse Init loaders before each event in subscription

func (LoadersInitializer) Validate

type PlaygroundConfig

type PlaygroundConfig struct {
	Enabled bool   `env:"GQL_PLAYGROUND_ENABLED, default=true"`
	Path    string `env:"GQL_PLAYGROUND_URL, default=/playground"`
}

type ServerParams

type ServerParams struct {
	fx.In

	Config             Config
	Schema             graphql.ExecutableSchema
	LoadersInitializer *LoadersInitializer `optional:"true"`
	Logger             *slog.Logger
	ErrorPresenter     graphql.ErrorPresenterFunc
}

Directories

Path Synopsis
install

Jump to

Keyboard shortcuts

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