model

package
v0.0.0-...-2ad8e27 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: GPL-3.0 Imports: 14 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 ArticleInput

type ArticleInput struct {
	ArticleID    string  `json:"articleId"`
	Quantity     int     `json:"quantity"`
	IsValid      bool    `json:"isValid"`
	UnitaryPrice float64 `json:"unitaryPrice"`
	IsValidated  bool    `json:"isValidated"`
}

type ComplexityRoot

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

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

	Mutation struct {
		CreatePayment func(childComplexity int, orderID string, payment *PaymentEventInput) int
	}

	Order struct {
		Articles func(childComplexity int) int
		CartID   func(childComplexity int) int
		ID       func(childComplexity int) int
		OrderID  func(childComplexity int) int
		Payments func(childComplexity int) int
		Status   func(childComplexity int) int
		UserID   func(childComplexity int) int
	}

	OrderArticle struct {
		Article      func(childComplexity int) int
		ArticleID    func(childComplexity int) int
		IsValid      func(childComplexity int) int
		IsValidated  func(childComplexity int) int
		Quantity     func(childComplexity int) int
		UnitaryPrice func(childComplexity int) int
	}

	OrderSummary struct {
		Articles     func(childComplexity int) int
		CartID       func(childComplexity int) int
		ID           func(childComplexity int) int
		Status       func(childComplexity int) int
		TotalPayment func(childComplexity int) int
		TotalPrice   func(childComplexity int) int
	}

	PaymentEvent struct {
		Amount func(childComplexity int) int
		Method func(childComplexity int) int
	}

	Query struct {
		GetOrder  func(childComplexity int, id string) int
		GetOrders func(childComplexity int) 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 {
	FindOrderByID(ctx context.Context, id string) (*Order, error)
}

type EntityWithIndex

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

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	CreatePayment(ctx context.Context, orderID string, payment *PaymentEventInput) (bool, error)
}

type Order

type Order struct {
	ID       string          `json:"id"`
	OrderID  string          `json:"orderId"`
	Status   OrderStatus     `json:"status"`
	UserID   string          `json:"userId"`
	CartID   string          `json:"cartId"`
	Articles []*OrderArticle `json:"articles,omitempty"`
	Payments []*PaymentEvent `json:"payments,omitempty"`
}

func (Order) IsEntity

func (Order) IsEntity()

type OrderArticle

type OrderArticle struct {
	ArticleID    string   `json:"articleId"`
	Article      *Article `json:"article,omitempty"`
	Quantity     int      `json:"quantity"`
	IsValid      bool     `json:"isValid"`
	UnitaryPrice float64  `json:"unitaryPrice"`
	IsValidated  bool     `json:"isValidated"`
}

type OrderStatus

type OrderStatus string
const (
	OrderStatusPlaced         OrderStatus = "PLACED"
	OrderStatusInvalid        OrderStatus = "INVALID"
	OrderStatusValidated      OrderStatus = "VALIDATED"
	OrderStatusPaymentDefined OrderStatus = "PAYMENT_DEFINED"
)

func (OrderStatus) IsValid

func (e OrderStatus) IsValid() bool

func (OrderStatus) MarshalGQL

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

func (OrderStatus) String

func (e OrderStatus) String() string

func (*OrderStatus) UnmarshalGQL

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

type OrderSummary

type OrderSummary struct {
	ID           string      `json:"id"`
	Status       OrderStatus `json:"status"`
	CartID       string      `json:"cartId"`
	TotalPrice   float64     `json:"totalPrice"`
	TotalPayment float64     `json:"totalPayment"`
	Articles     int         `json:"articles"`
}

type PaymentEvent

type PaymentEvent struct {
	Method PaymentMethod `json:"method"`
	Amount float64       `json:"amount"`
}

type PaymentEventInput

type PaymentEventInput struct {
	Method PaymentMethod `json:"method"`
	Amount float64       `json:"amount"`
}

type PaymentMethod

type PaymentMethod string
const (
	PaymentMethodCash   PaymentMethod = "CASH"
	PaymentMethodCredit PaymentMethod = "CREDIT"
	PaymentMethodDebit  PaymentMethod = "DEBIT"
)

func (PaymentMethod) IsValid

func (e PaymentMethod) IsValid() bool

func (PaymentMethod) MarshalGQL

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

func (PaymentMethod) String

func (e PaymentMethod) String() string

func (*PaymentMethod) UnmarshalGQL

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

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	GetOrder(ctx context.Context, id string) (*Order, error)
	GetOrders(ctx context.Context) ([]*OrderSummary, error)
}

type ResolverRoot

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

Jump to

Keyboard shortcuts

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