model

package
v0.0.0-...-6aeb5bb Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

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 Article

type Article struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Image       string  `json:"image"`
	Price       float64 `json:"price"`
	Stock       int     `json:"stock"`
}

func (Article) IsEntity

func (Article) IsEntity()

type ComplexityRoot

type ComplexityRoot struct {
	Article struct {
		Description func(childComplexity int) int
		ID          func(childComplexity int) int
		Image       func(childComplexity int) int
		Name        func(childComplexity int) int
		Price       func(childComplexity int) int
		Stock       func(childComplexity int) int
	}

	Entity struct {
		FindArticleByID func(childComplexity int, id string) int
	}

	Mutation struct {
		CreateArticle func(childComplexity int, input UpdateArticle) int
		DeleteArticle func(childComplexity int, id string) int
		UpdateArticle func(childComplexity int, input UpdateArticle) int
	}

	Query struct {
		GetArticle     func(childComplexity int, id string) int
		SearchArticles func(childComplexity int, criteria string) int
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

type Config

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

type DirectiveRoot

type DirectiveRoot struct {
}

type EntityRepresentation

type EntityRepresentation map[string]any

EntityRepresentation is the JSON representation of an entity sent by the Router used as the inputs for us to resolve.

We make it a map because we know the top level JSON is always an object.

type EntityResolver

type EntityResolver interface {
	FindArticleByID(ctx context.Context, id string) (*Article, error)
}

type EntityWithIndex

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

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	DeleteArticle(ctx context.Context, id string) (bool, error)
	CreateArticle(ctx context.Context, input UpdateArticle) (bool, error)
	UpdateArticle(ctx context.Context, input UpdateArticle) (bool, error)
}

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	GetArticle(ctx context.Context, id string) (*Article, error)
	SearchArticles(ctx context.Context, criteria string) ([]*Article, error)
}

type ResolverRoot

type ResolverRoot interface {
	Entity() EntityResolver
	Mutation() MutationResolver
	Query() QueryResolver
}

type UpdateArticle

type UpdateArticle struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Image       string  `json:"image"`
	Price       float64 `json:"price"`
	Stock       int     `json:"stock"`
}

Jump to

Keyboard shortcuts

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