graphapi

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package graphapi contains the GraphQL resolvers for tenant-api.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType  = errors.New("unknown type")
	ErrTypeNotFound = errors.New("type not found")
)

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Entity struct {
		FindTenantByID func(childComplexity int, id gidx.PrefixedID) int
	}

	Mutation struct {
		TenantCreate func(childComplexity int, input generated.CreateTenantInput) int
		TenantDelete func(childComplexity int, id gidx.PrefixedID) int
		TenantUpdate func(childComplexity int, id gidx.PrefixedID, input generated.UpdateTenantInput) int
	}

	PageInfo struct {
		EndCursor       func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		StartCursor     func(childComplexity int) int
	}

	Query struct {
		Tenant func(childComplexity int, id gidx.PrefixedID) int
		// contains filtered or unexported fields
	}

	Tenant struct {
		Children    func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.TenantOrder, where *generated.TenantWhereInput) int
		CreatedAt   func(childComplexity int) int
		Description func(childComplexity int) int
		ID          func(childComplexity int) int
		Name        func(childComplexity int) int
		Parent      func(childComplexity int) int
		UpdatedAt   func(childComplexity int) int
	}

	TenantConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	TenantCreatePayload struct {
		Tenant func(childComplexity int) int
	}

	TenantDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	TenantEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	TenantUpdatePayload struct {
		Tenant func(childComplexity int) int
	}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
	ComposeDirective func(ctx context.Context, obj interface{}, next graphql.Resolver, name string) (res interface{}, err error)
}

type EntityResolver

type EntityResolver interface {
	FindTenantByID(ctx context.Context, id gidx.PrefixedID) (*generated.Tenant, error)
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is an http handler wrapping a Resolver

func (*Handler) Handler

func (h *Handler) Handler() http.HandlerFunc

Handler returns the http.HandlerFunc for the GraphAPI

func (*Handler) Routes

func (h *Handler) Routes(e *echo.Group)

Routes ...

type MutationResolver

type MutationResolver interface {
	TenantCreate(ctx context.Context, input generated.CreateTenantInput) (*TenantCreatePayload, error)
	TenantUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateTenantInput) (*TenantUpdatePayload, error)
	TenantDelete(ctx context.Context, id gidx.PrefixedID) (*TenantDeletePayload, error)
}

type QueryResolver

type QueryResolver interface {
	Tenant(ctx context.Context, id gidx.PrefixedID) (*generated.Tenant, error)
}

type Resolver

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

Resolver provides a graph response resolver

func NewResolver

func NewResolver(client *ent.Client, logger *zap.SugaredLogger) *Resolver

NewResolver returns a resolver configured with the given ent client

func (*Resolver) Entity

func (r *Resolver) Entity() EntityResolver

Entity returns EntityResolver implementation.

func (*Resolver) Handler

func (r *Resolver) Handler(withPlayground bool, middleware []echo.MiddlewareFunc) *Handler

Handler returns an http handler for a graph 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 {
	Entity() EntityResolver
	Mutation() MutationResolver
	Query() QueryResolver
}

type TenantCreatePayload

type TenantCreatePayload struct {
	// The created tenant.
	Tenant *generated.Tenant `json:"tenant"`
}

Return response from tenantCreate.

type TenantDeletePayload

type TenantDeletePayload struct {
	// The ID of the deleted tenant.
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response from tenantDelete.

type TenantUpdatePayload

type TenantUpdatePayload struct {
	// The updated tenant.
	Tenant *generated.Tenant `json:"tenant"`
}

Return response from tenantUpdate.

Jump to

Keyboard shortcuts

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