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 = `` /* 644-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") // EventHooksTemplate adds support for generating event hooks EventHooksTemplate = parseT("template/event_hooks.tmpl") // TemplateFuncs contains the extra template functions used by entx. TemplateFuncs = template.FuncMap{ "contains": strings.Contains, } )
var EventsHookAnnotationName = "INFRA9_EVENTHOOKS"
EventsHookAnnotationName 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 EventsHookAnnotation ¶ added in v0.1.2
type EventsHookAnnotation struct { SubjectName string AdditionalSubjectRelation string IsAdditionalSubjectField bool }
EventsHookAnnotation provides a ent.Annotation spec. These shouldn't be set directly, you should use EventsHookAdditionalSubject(), EventsHookAdditionalSubjectField() and EventsHookSubjectName() instead
func EventsHookAdditionalSubject ¶ added in v0.1.2
func EventsHookAdditionalSubject(relation string) *EventsHookAnnotation
EventsHookAdditionalSubject marks this ent field as a field to return as an additional subject relationship
func EventsHookAdditionalSubjectField ¶ added in v0.4.0
func EventsHookAdditionalSubjectField() *EventsHookAnnotation
EventsHookAdditionalSubjectField marks this ent field as a field to return an additional subject in the change event
func EventsHookSubjectName ¶ added in v0.1.2
func EventsHookSubjectName(s string) *EventsHookAnnotation
EventsHookSubjectName sets the subject name that is where the messages for this object will be sent
func (EventsHookAnnotation) Name ¶ added in v0.1.2
func (a EventsHookAnnotation) 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 WithEventHooks ¶ added in v0.1.2
func WithEventHooks() ExtensionOption
WithEventHooks adds the templates for generating event hooks
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 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