repository

package
v0.0.0-...-d70ac1d Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotFound = Error("could not find the item you were looking for")
)

Variables

This section is empty.

Functions

func DecodeCursor

func DecodeCursor(cursor string) (*todoCursor, error)

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type InMemoryTodoRepository

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

InMemoryTodoRepository - for in-mem hackery...

func (*InMemoryTodoRepository) Delete

func (r *InMemoryTodoRepository) Delete(ids []string) (errors []error)

func (*InMemoryTodoRepository) GetTodos

func (r *InMemoryTodoRepository) GetTodos() (todos []*TodoItem, err error)

func (*InMemoryTodoRepository) GetTodosById

func (r *InMemoryTodoRepository) GetTodosById(ids []string) (todos []*TodoItem, errors []error)

func (*InMemoryTodoRepository) Upsert

func (r *InMemoryTodoRepository) Upsert(items []*TodoItem) (todos []*TodoItem, errors []error)

type NullableID

type NullableID struct {
	Value string
}

type TodoItem

type TodoItem struct {
	ID     *NullableID // shenanigans to allow for null ID...  some other mechanism would likely be more appropriate for a "real" store.
	Text   string
	Done   bool
	UserID string
}

func (*TodoItem) EncodeCursor

func (ti *TodoItem) EncodeCursor(index int) string

func (*TodoItem) ToTodo

func (ti *TodoItem) ToTodo() *model.Todo

type TodoRepository

type TodoRepository interface {
	GetTodos() (todos []*TodoItem, err error)

	GetTodosById(ids []string) (todos []*TodoItem, errors []error)

	Upsert(items []*TodoItem) (todos []*TodoItem, errors []error)

	Delete(ids []string) (errors []error)
}

TodoRepository stuff... ... PoCing a "repository" pattern integrated with DataLoader pattern, and demonstrating that persistence model != graphql schema model (hence there's a TodoItem struct here that is the repository's type for TODOs... which is separate from the graph.model.Todo)

func NewInMemoryTodoRepository

func NewInMemoryTodoRepository() TodoRepository

Jump to

Keyboard shortcuts

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