graphfx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package graphfx is the glue between nexus and github.com/paulmanoni/go-graph. Drop graphfx.Module into your fx.New(...), wrap your resolver constructors with AsQuery/AsMutation/AsSubscription, and mount with ServeAt.

As of go-graph v1.2.4, graphfx introspects every resolver after mounting and enriches the nexus registry with: return type, per-arg Required flag and default values, per-arg validator metadata (from graph.WithArgValidator), per-resolver named middleware chain (from graph.WithNamedMiddleware), and deprecation info (from graph.WithDeprecated). Dashboards consume this without the user declaring anything separately.

Typical usage:

fx.New(
    fxmod.Module,
    graphfx.Module,
    fx.Provide(
        graphfx.AsQuery(NewGetAllAdverts),
        graphfx.AsMutation(NewCreateAdvert),
    ),
    graphfx.ServeAt("adverts", "/graphql",
        graphfx.Describe("Job adverts catalog"),
        graphfx.UseDefaults(),
    ),
)

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("graphfx",
	fx.Provide(provideBundle),
)

Module provides *Bundle into the fx graph. A Bundle holds both the assembled *graph.SchemaBuilder and the raw resolver slices, so ServeAt can introspect every resolver after mount.

Functions

func AsMutation

func AsMutation(ctor any) any

AsMutation — like AsQuery, for mutations.

func AsQuery

func AsQuery(ctor any) any

AsQuery annotates a constructor so Fx stores its result in the "query_fields" value group that SchemaBuilderParams consumes.

func AsSubscription

func AsSubscription(ctor any) any

AsSubscription — like AsQuery, for subscriptions.

func ServeAt

func ServeAt(service, path string, opts ...Opt) fx.Option

ServeAt returns an fx.Option that, once fx.Start runs:

  1. builds the schema from the injected *Bundle
  2. mounts it on the named service at path
  3. introspects every resolver and patches the registry with per-resolver middleware names, arg validators, return types, and deprecation

Types

type Bundle

type Bundle struct {
	Builder       *graph.SchemaBuilder
	Queries       []graph.QueryField
	Mutations     []graph.MutationField
	Subscriptions []graph.SubscriptionField
}

Bundle carries both the schema builder and the raw field slices so ServeAt can introspect each resolver after mount. You normally don't construct this yourself; graphfx.Module provides it.

type Opt

type Opt func(*mountConfig)

Opt configures a ServeAt call.

func Describe

func Describe(s string) Opt

Describe sets the service's human description (dashboard header).

func Use

func Use(names ...string) Opt

Use attaches the named resources to the service. Empty string = default DB.

func UseDefaults

func UseDefaults() Opt

UseDefaults attaches the default database, cache, and queue (if registered).

func WithGQL

func WithGQL(opts ...gql.Option) Opt

WithGQL forwards gql.Option values (UserDetailsFn, Playground, Pretty, DEBUG) to the underlying MountGraphQL call. Typical use:

graphfx.ServeAt("adverts", "/graphql",
    graphfx.WithGQL(gql.WithUserDetailsFn(auth.Fetch)),
)

Jump to

Keyboard shortcuts

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