entgql

package
v0.0.0-...-86c7de4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CollectionTemplate adds fields collection support using auto eager-load ent edges.
	// More info can be found here: https://spec.graphql.org/June2018/#sec-Field-Collection.
	CollectionTemplate = parse("template/collection.tmpl")

	// EnumTemplate adds a template implementing MarshalGQL/UnmarshalGQL methods for enums.
	EnumTemplate = parse("template/enum.tmpl")

	// NodeTemplate implements the Relay Node interface for all types.
	NodeTemplate = parse("template/node.tmpl")

	// PaginationTemplate adds pagination support according to the GraphQL Cursor Connections Spec.
	// More info can be found in the following link: https://relay.dev/graphql/connections.htm.
	PaginationTemplate = parse("template/pagination.tmpl")

	// TransactionTemplate adds support for ent.Client for opening transactions for the transaction
	// middleware. See transaction.go for for information.
	TransactionTemplate = parse("template/transaction.tmpl")

	// EdgeTemplate adds edge resolution using eager-loading with a query fallback.
	EdgeTemplate = parse("template/edge.tmpl")

	// AllTemplates holds all templates for extending ent to support GraphQL.
	AllTemplates = []*gen.Template{
		CollectionTemplate,
		EnumTemplate,
		NodeTemplate,
		PaginationTemplate,
		TransactionTemplate,
		EdgeTemplate,
	}
)

Functions

func ErrNodeNotFound

func ErrNodeNotFound(id interface{}) *gqlerror.Error

ErrNodeNotFound creates a node not found graphql error.

Types

type Annotation

type Annotation struct {
	// OrderField is the ordering field as defined in graphql schema.
	OrderField string
	// Bind implies the edge field name in graphql schema
	// is equivalent to the name used in ent schema.
	Bind bool
	// Mapping is the edge field names as defined in graphql schema.
	Mapping []string
}

Annotation annotates fields and edges with metadata for templates.

func Bind

func Bind() Annotation

Bind returns a binding annotation.

func MapsTo

func MapsTo(names ...string) Annotation

MapsTo returns a mapping annotation.

func OrderField

func OrderField(name string) Annotation

OrderField returns an order field annotation.

func (Annotation) Merge

func (a Annotation) Merge(other schema.Annotation) schema.Annotation

Merge implements the schema.Merger interface.

func (Annotation) Name

func (Annotation) Name() string

Name implements ent.Annotation interface.

type Transactioner

type Transactioner struct{ TxOpener }

Transactioner for graphql mutations.

func (Transactioner) ExtensionName

func (Transactioner) ExtensionName() string

ExtensionName returns the extension name.

func (Transactioner) InterceptResponse

func (t Transactioner) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response

InterceptResponse runs graphql mutations under a transaction.

func (Transactioner) MutateOperationContext

func (Transactioner) MutateOperationContext(_ context.Context, oc *graphql.OperationContext) *gqlerror.Error

MutateOperationContext serializes field resolvers during mutations.

func (Transactioner) Validate

Validate is called when adding an extension to the server, it allows validation against the servers schema.

type TxOpener

type TxOpener interface {
	OpenTx(ctx context.Context) (context.Context, driver.Tx, error)
}

TxOpener represents types than can open transactions.

type TxOpenerFunc

type TxOpenerFunc func(ctx context.Context) (context.Context, driver.Tx, error)

The TxOpenerFunc type is an adapter to allow the use of ordinary functions as tx openers.

func (TxOpenerFunc) OpenTx

OpenTx returns f(ctx).

Jump to

Keyboard shortcuts

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