model

package
v0.0.0-...-7639478 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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"`
}

func (Article) IsEntity

func (Article) IsEntity()

type Cart

type Cart struct {
	ID       string         `json:"id"`
	UserID   string         `json:"userId"`
	User     *User          `json:"user,omitempty"`
	OrderID  *string        `json:"orderId,omitempty"`
	Order    *Order         `json:"order,omitempty"`
	Articles []*CartArticle `json:"articles"`
	Enabled  bool           `json:"enabled"`
}

func (Cart) IsEntity

func (Cart) IsEntity()

type CartArticle

type CartArticle struct {
	ArticleID string   `json:"articleId"`
	Article   *Article `json:"article,omitempty"`
	Quantity  int      `json:"quantity"`
	Valid     bool     `json:"valid"`
	Validated bool     `json:"validated"`
}

type ComplexityRoot

type ComplexityRoot struct {
	Article struct {
		ID func(childComplexity int) int
	}

	Cart struct {
		Articles func(childComplexity int) int
		Enabled  func(childComplexity int) int
		ID       func(childComplexity int) int
		Order    func(childComplexity int) int
		OrderID  func(childComplexity int) int
		User     func(childComplexity int) int
		UserID   func(childComplexity int) int
	}

	CartArticle struct {
		Article   func(childComplexity int) int
		ArticleID func(childComplexity int) int
		Quantity  func(childComplexity int) int
		Valid     func(childComplexity int) int
		Validated func(childComplexity int) int
	}

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

	Mutation struct {
		AddArticle       func(childComplexity int, articleID string, quantity int) int
		Checkout         func(childComplexity int) int
		DecrementArticle func(childComplexity int, articleID string) int
		IncrementArticle func(childComplexity int, articleID string) int
		RemoveArticle    func(childComplexity int, articleID string) int
		ValidateCart     func(childComplexity int) int
	}

	Order struct {
		ID func(childComplexity int) int
	}

	Query struct {
		CurrentCart func(childComplexity int) int
		// contains filtered or unexported fields
	}

	User struct {
		ID func(childComplexity int) int
	}
	// 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 {
	FindCartByID(ctx context.Context, id string) (*Cart, error)
}

type EntityWithIndex

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

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	ValidateCart(ctx context.Context) (bool, error)
	DecrementArticle(ctx context.Context, articleID string) (bool, error)
	IncrementArticle(ctx context.Context, articleID string) (bool, error)
	RemoveArticle(ctx context.Context, articleID string) (bool, error)
	AddArticle(ctx context.Context, articleID string, quantity int) (bool, error)
	Checkout(ctx context.Context) (bool, error)
}

type Order

type Order struct {
	ID string `json:"id"`
}

func (Order) IsEntity

func (Order) IsEntity()

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	CurrentCart(ctx context.Context) (*Cart, error)
}

type ResolverRoot

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

type User

type User struct {
	ID string `json:"id"`
}

func (User) IsEntity

func (User) IsEntity()

Jump to

Keyboard shortcuts

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