usefunctionsyntaxforexecutioncontext

package
v0.17.60 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllRole = []Role{
	RoleAdmin,
	RoleUser,
	RoleGuest,
}

Functions

func LogDirective

func LogDirective(ctx context.Context, obj any, next graphql.Resolver, message *string) (res any, err error)

LogDirective implementation

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type Admin

type Admin struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Permissions []string `json:"permissions"`
	CreatedAt   *string  `json:"createdAt,omitempty"`
}

func (Admin) GetCreatedAt

func (this Admin) GetCreatedAt() *string

func (Admin) GetID

func (this Admin) GetID() string

func (Admin) IsEntity

func (Admin) IsEntity()

type ComplexityRoot

type ComplexityRoot struct {
	Admin struct {
		CreatedAt   func(childComplexity int) int
		ID          func(childComplexity int) int
		Name        func(childComplexity int) int
		Permissions func(childComplexity int) int
	}

	Mutation struct {
		CreateUser func(childComplexity int, input CreateUserInput) int
		DeleteUser func(childComplexity int, id string) int
	}

	MutationResponse struct {
		Message func(childComplexity int) int
		Success func(childComplexity int) int
	}

	Query struct {
		GetEntity func(childComplexity int, id string) int
		GetUser   func(childComplexity int, id string) int
		ListUsers func(childComplexity int, filter *UserFilter) int
	}

	Subscription struct {
		UserCreated func(childComplexity int) int
	}

	User struct {
		Age       func(childComplexity int) int
		CreatedAt func(childComplexity int) int
		Email     func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Role      func(childComplexity int) int
	}
}

type Config

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

type CreateUserInput

type CreateUserInput struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Age   *int   `json:"age,omitempty"`
	Role  *Role  `json:"role,omitempty"`
}

type DirectiveRoot

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

type Entity

type Entity interface {
	IsEntity()
	GetID() string
	GetCreatedAt() *string
}

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	CreateUser(ctx context.Context, input CreateUserInput) (*User, error)
	DeleteUser(ctx context.Context, id string) (*MutationResponse, error)
}

type MutationResponse

type MutationResponse struct {
	Success bool    `json:"success"`
	Message *string `json:"message,omitempty"`
}

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	GetUser(ctx context.Context, id string) (*User, error)
	ListUsers(ctx context.Context, filter *UserFilter) ([]*User, error)
	GetEntity(ctx context.Context, id string) (Entity, error)
}

type Resolver

type Resolver struct{}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

func (*Resolver) Subscription

func (r *Resolver) Subscription() SubscriptionResolver

Subscription returns SubscriptionResolver implementation.

type ResolverRoot

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

type Role

type Role string
const (
	RoleAdmin Role = "ADMIN"
	RoleUser  Role = "USER"
	RoleGuest Role = "GUEST"
)

func (Role) IsValid

func (e Role) IsValid() bool

func (Role) MarshalGQL

func (e Role) MarshalGQL(w io.Writer)

func (Role) String

func (e Role) String() string

func (*Role) UnmarshalGQL

func (e *Role) UnmarshalGQL(v interface{}) error

type Stub

type Stub struct {
	MutationResolver struct {
		CreateUser func(ctx context.Context, input CreateUserInput) (*User, error)
		DeleteUser func(ctx context.Context, id string) (*MutationResponse, error)
	}
	QueryResolver struct {
		GetUser   func(ctx context.Context, id string) (*User, error)
		ListUsers func(ctx context.Context, filter *UserFilter) ([]*User, error)
		GetEntity func(ctx context.Context, id string) (Entity, error)
	}
	SubscriptionResolver struct {
		UserCreated func(ctx context.Context) (<-chan *User, error)
	}
}

func (*Stub) Mutation

func (r *Stub) Mutation() MutationResolver

func (*Stub) Query

func (r *Stub) Query() QueryResolver

func (*Stub) Subscription

func (r *Stub) Subscription() SubscriptionResolver

type Subscription

type Subscription struct {
}

type SubscriptionResolver

type SubscriptionResolver interface {
	UserCreated(ctx context.Context) (<-chan *User, error)
}

type User

type User struct {
	ID        string  `json:"id"`
	Name      string  `json:"name"`
	Email     string  `json:"email"`
	Age       *int    `json:"age,omitempty"`
	Role      Role    `json:"role"`
	CreatedAt *string `json:"createdAt,omitempty"`
}

func (User) GetCreatedAt

func (this User) GetCreatedAt() *string

func (User) GetID

func (this User) GetID() string

func (User) IsEntity

func (User) IsEntity()

type UserFilter

type UserFilter struct {
	Name     *string `json:"name,omitempty"`
	Email    *string `json:"email,omitempty"`
	Age      *int    `json:"age,omitempty"`
	Roles    []Role  `json:"roles,omitempty"`
	IsActive *bool   `json:"isActive,omitempty"`
}

Jump to

Keyboard shortcuts

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