wiring

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailPasswordLoginHandler

type EmailPasswordLoginHandler interface {
	Login(ctx context.Context, email, password string, accountID ...uint64) (*gqlmodels.SessionToken, error)
}

EmailPasswordLoginHandler handles the login(email, password, accountID) mutation.

type ExampleAccountQueryResolver

ExampleAccountQueryResolver is account QueryResolver wired to example GraphQL models.

func NewExampleAccountQueryResolver

func NewExampleAccountQueryResolver(cfg ExampleAccountQueryResolverConfig) *ExampleAccountQueryResolver

NewExampleAccountQueryResolver wires account resolvers with extended GraphQL models.

type Option

type Option func(*OptionsConfig)

Option is a functional option applied to OptionsConfig.

func WithUserAccountResolvers

func WithUserAccountResolvers[TUser user.Model, TAccount account.Model](
	provider *jwt.Provider,
	user UserQueryResolver,
	auth *accountgraphql.AuthResolver[TUser, TAccount],
	accounts AccountQueryHandler,
	members accountgraphql.MemberQueryHandler,
) Option

WithUserAccountResolvers sets all four custom resolvers in one call. auth must be the concrete *AuthResolver so that the email+password login handler can be wired automatically via accountlogin.New(auth).

Example:

graphql.WithUserAccountResolvers[*domain.User, *domain.Account](
    wiring.NewExampleUserQueryResolver(deps.UserModule),
    accountgraphql.NewAuthResolver(jwtProvider, login, deps.AccountRepo, deps.AccountUC, rbacrepo.New()),
    wiring.NewExampleAccountQueryResolver(cfg),
    wiring.NewExampleMemberQueryResolver(deps.AccountUC, deps.MemberUC, ...),
)

func WithUserLoginHandler

func WithUserLoginHandler[TUser user.Model, TAccount account.Model](
	provider *jwt.Provider,
	userLogin accountlogin.LoginPasswordAuth[TUser],
	sessionRepo account.SessionRepository[TUser, TAccount],
) Option

WithUserLoginHandler sets the email+password login handler for the example/api GraphQL handler. auth must be the concrete *AuthResolver so that the email+password login handler can be wired automatically via accountlogin.New(auth).

type OptionsConfig

type OptionsConfig struct {
	UserHandler    UserQueryResolver
	AuthHandler    accountgraphql.AuthQueryHandler
	LoginHandler   accountgraphql.AccountLoginHandler
	AccountHandler AccountQueryHandler
	MemberHandler  accountgraphql.MemberQueryHandler
}

OptionsConfig carries all resolver overrides for the example/api GraphQL handler. Instantiate with concrete user/account types at the entry point (e.g. main.go).

func Apply

func Apply(opts []Option, cfg *OptionsConfig) *OptionsConfig

Apply runs all options against cfg and returns it.

type UserQueryResolver

func NewExampleUserQueryResolver

func NewExampleUserQueryResolver(module userstack.Module[*domain.User]) UserQueryResolver

NewExampleUserQueryResolver wires a full user resolver from a userstack Module.

func NewUserQueryResolver

func NewUserQueryResolver(
	core user.Usecase[*domain.User],
	emailUsecase user.EmailUsecase[*domain.User],
	passwordUsecase user.PasswordUsecase[*domain.User],
) UserQueryResolver

Jump to

Keyboard shortcuts

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