Documentation ¶
Overview ¶
Package entx is a package of tools for interacting with ent. Providing tools to make generating federated gql easier, working with JSON values in ent, and provided helpers for using idx as your ID on types.
Index ¶
Constants ¶
const CopyrightHeader string = `` /* 647-byte string literal not displayed */
Variables ¶
var ( // FederationTemplate adds support for generating the required output to support gql federation FederationTemplate = parseT("template/gql_federation.tmpl") // NamespacedDataWhereFuncsTemplate adds support for generating <T>WhereInput filters for schema types using the NamespacedData mixin NamespacedDataWhereFuncsTemplate = parseT("template/namespaceddata_where_funcs.tmpl") // TemplateFuncs contains the extra template functions used by entx. TemplateFuncs = template.FuncMap{} // MixinTemplates includes all templates for extending ent to support entx mixins. MixinTemplates = []*gen.Template{ NamespacedDataWhereFuncsTemplate, } )
var AnnotationName = "I12R_ENTX"
AnnotationName is the value of the annotation when read during ent compilation
Functions ¶
func GraphKeyDirective ¶
func GraphKeyDirective(fields string) entgql.Annotation
GraphKeyDirective returns an entgql.Directive for setting the @key field on a graphql type
func MarshalRawMessage ¶
func MarshalRawMessage(t json.RawMessage) graphql.Marshaler
MarshalRawMessage provides a graphql.Marshaler for json.RawMessage
func UnmarshalRawMessage ¶
func UnmarshalRawMessage(v interface{}) (json.RawMessage, error)
UnmarshalRawMessage provides a graphql.Unmarshaler for json.RawMessage
Types ¶
type Annotation ¶
type Annotation struct {
IsNamespacedDataJSONField bool
}
Annotation provides a ent.Annotaion spec
func (Annotation) Name ¶
func (a Annotation) Name() string
Name implements the ent Annotation interface.
type Extension ¶
type Extension struct { entc.DefaultExtension // contains filtered or unexported fields }
Extension is an implementation of entc.Extension that adds all the templates that entx needs.
func NewExtension ¶
func NewExtension(opts ...ExtensionOption) (*Extension, error)
NewExtension returns an entc Extension that allows the entx package to generate the schema changes and templates needed to function
func (*Extension) GQLSchemaHooks ¶
func (e *Extension) GQLSchemaHooks() []entgql.SchemaHook
GQLSchemaHooks of the extension to seamlessly edit the final gql interface.
type ExtensionOption ¶
ExtensionOption allow for control over the behavior of the generator
func WithFederation ¶
func WithFederation() ExtensionOption
WithFederation adds support for graphql federation by adding the Entity interface to all types, as well as removing the node() and nodes() query calls.
func WithJSONScalar ¶
func WithJSONScalar() ExtensionOption
WithJSONScalar adds the JSON scalar definition
type NamespacedDataMixin ¶
NamespacedDataMixin defines an ent Mixin that captures raw json associated with a namespace.
func (NamespacedDataMixin) Fields ¶
func (m NamespacedDataMixin) Fields() []ent.Field
Fields provides the namespace and data fields used in this mixin.
type TimestampsMixin ¶
type TimestampsMixin interface { ent.Mixin CreatedAtAnnotations(...schema.Annotation) TimestampsMixin UpdatedAtAnnotations(...schema.Annotation) TimestampsMixin }
TimestampsMixin defines an interface of a Mixin that provides the created_at and updated_at timestamp fields
func NewTimestampMixin ¶
func NewTimestampMixin() TimestampsMixin
NewTimestampMixin returns a Mixin that provides the created_at and updated_at timestamp fields