graphapi

package
v0.0.0-...-2440c84 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package graphapi does graph stuff

Index

Constants

View Source
const (
	ActionGet    = "get"
	ActionUpdate = "update"
	ActionDelete = "delete"
	ActionCreate = "create"
)

Variables

View Source
var (
	// ErrCascadeDelete is returned when an error occurs while performing cascade deletes on associated objects
	ErrCascadeDelete = errors.New("error deleting associated objects")
)

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func WithTransactions

func WithTransactions(h *handler.Server, c *ent.Client)

WithTransactions adds the transactioner to the ent db client

Types

type ComplexityRoot

type ComplexityRoot struct {
	Database struct {
		CreatedAt      func(childComplexity int) int
		CreatedBy      func(childComplexity int) int
		DeletedAt      func(childComplexity int) int
		DeletedBy      func(childComplexity int) int
		Dsn            func(childComplexity int) int
		Geo            func(childComplexity int) int
		Group          func(childComplexity int) int
		GroupID        func(childComplexity int) int
		ID             func(childComplexity int) int
		Name           func(childComplexity int) int
		OrganizationID func(childComplexity int) int
		Provider       func(childComplexity int) int
		Status         func(childComplexity int) int
		UpdatedAt      func(childComplexity int) int
		UpdatedBy      func(childComplexity int) int
	}

	DatabaseConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	DatabaseCreatePayload struct {
		Database func(childComplexity int) int
	}

	DatabaseDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	DatabaseEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	DatabaseUpdatePayload struct {
		Database func(childComplexity int) int
	}

	Group struct {
		CreatedAt       func(childComplexity int) int
		CreatedBy       func(childComplexity int) int
		Databases       func(childComplexity int) int
		DeletedAt       func(childComplexity int) int
		DeletedBy       func(childComplexity int) int
		Description     func(childComplexity int) int
		ID              func(childComplexity int) int
		Locations       func(childComplexity int) int
		Name            func(childComplexity int) int
		PrimaryLocation func(childComplexity int) int
		Region          func(childComplexity int) int
		UpdatedAt       func(childComplexity int) int
		UpdatedBy       func(childComplexity int) int
	}

	GroupConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	GroupCreatePayload struct {
		Group func(childComplexity int) int
	}

	GroupDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	GroupEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	GroupUpdatePayload struct {
		Group func(childComplexity int) int
	}

	Mutation struct {
		CreateDatabase func(childComplexity int, input generated.CreateDatabaseInput) int
		CreateGroup    func(childComplexity int, input generated.CreateGroupInput) int
		DeleteDatabase func(childComplexity int, name string) int
		DeleteGroup    func(childComplexity int, name string) int
		UpdateDatabase func(childComplexity int, name string, input generated.UpdateDatabaseInput) int
		UpdateGroup    func(childComplexity int, name string, input generated.UpdateGroupInput) int
	}

	PageInfo struct {
		EndCursor       func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		StartCursor     func(childComplexity int) int
	}

	Query struct {
		Database  func(childComplexity int, name string) int
		Databases func(childComplexity int, after *entgql.Cursor[string], first *int, before *entgql.Cursor[string], last *int, where *generated.DatabaseWhereInput) int
		Group     func(childComplexity int, name string) int
		Groups    func(childComplexity int, after *entgql.Cursor[string], first *int, before *entgql.Cursor[string], last *int, where *generated.GroupWhereInput) int
		Node      func(childComplexity int, id string) int
		Nodes     func(childComplexity int, ids []string) int
	}
}

type Config

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

type DatabaseCreatePayload

type DatabaseCreatePayload struct {
	// Created database
	Database *generated.Database `json:"database"`
}

Return response for createDatabase mutation

type DatabaseDeletePayload

type DatabaseDeletePayload struct {
	// Deleted database ID
	DeletedID string `json:"deletedID"`
}

Return response for deleteDatabase mutation

type DatabaseUpdatePayload

type DatabaseUpdatePayload struct {
	// Updated database
	Database *generated.Database `json:"database"`
}

Return response for updateDatabase mutation

type DirectiveRoot

type DirectiveRoot struct {
}

type GroupCreatePayload

type GroupCreatePayload struct {
	// Created group
	Group *generated.Group `json:"group"`
}

Return response for createGroup mutation

type GroupDeletePayload

type GroupDeletePayload struct {
	// Deleted group ID
	DeletedID string `json:"deletedID"`
}

Return response for deleteGroup mutation

type GroupUpdatePayload

type GroupUpdatePayload struct {
	// Updated group
	Group *generated.Group `json:"group"`
}

Return response for updateGroup mutation

type Handler

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

Handler is an http handler wrapping a Resolver

func (*Handler) Handler

func (h *Handler) Handler() http.HandlerFunc

Handler returns the http.HandlerFunc for the GraphAPI

func (*Handler) Routes

func (h *Handler) Routes(e *echo.Group)

Routes for the the server

type MutationResolver

type MutationResolver interface {
	CreateDatabase(ctx context.Context, input generated.CreateDatabaseInput) (*DatabaseCreatePayload, error)
	UpdateDatabase(ctx context.Context, name string, input generated.UpdateDatabaseInput) (*DatabaseUpdatePayload, error)
	DeleteDatabase(ctx context.Context, name string) (*DatabaseDeletePayload, error)
	CreateGroup(ctx context.Context, input generated.CreateGroupInput) (*GroupCreatePayload, error)
	UpdateGroup(ctx context.Context, name string, input generated.UpdateGroupInput) (*GroupUpdatePayload, error)
	DeleteGroup(ctx context.Context, name string) (*GroupDeletePayload, error)
}

type QueryResolver

type QueryResolver interface {
	Node(ctx context.Context, id string) (generated.Noder, error)
	Nodes(ctx context.Context, ids []string) ([]generated.Noder, error)
	Databases(ctx context.Context, after *entgql.Cursor[string], first *int, before *entgql.Cursor[string], last *int, where *generated.DatabaseWhereInput) (*generated.DatabaseConnection, error)
	Groups(ctx context.Context, after *entgql.Cursor[string], first *int, before *entgql.Cursor[string], last *int, where *generated.GroupWhereInput) (*generated.GroupConnection, error)
	Database(ctx context.Context, name string) (*generated.Database, error)
	Group(ctx context.Context, name string) (*generated.Group, error)
}

type Resolver

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

Resolver provides a graph response resolver

func NewResolver

func NewResolver(client *ent.Client) *Resolver

NewResolver returns a resolver configured with the given ent client

func (*Resolver) Handler

func (r *Resolver) Handler(withPlayground bool) *Handler

Handler returns an http handler for a graph resolver

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) WithLogger

func (r Resolver) WithLogger(l *zap.SugaredLogger) *Resolver

type ResolverRoot

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

Jump to

Keyboard shortcuts

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