Documentation ¶
Overview ¶
Package pubsubinfo 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 ¶ added in v0.0.25
func GraphKeyDirective(fields string) entgql.Annotation
GraphKeyDirective returns an entgql.Directive for setting the @key field on a graphql type
func MarshalRawMessage ¶ added in v0.0.25
func MarshalRawMessage(t json.RawMessage) graphql.Marshaler
MarshalRawMessage provides a graphql.Marshaler for json.RawMessage
func UnmarshalRawMessage ¶ added in v0.0.25
func UnmarshalRawMessage(v interface{}) (json.RawMessage, error)
UnmarshalRawMessage provides a graphql.Unmarshaler for json.RawMessage
Types ¶
type EventsHookAnnotation ¶ added in v0.0.25
EventsHookAnnotation provides a ent.Annotation spec. These shouldn't be set directly, you should use EventsHookAdditionalSubject() and EventsHookSubjectName instead
func EventsHookAdditionalSubject ¶ added in v0.0.25
func EventsHookAdditionalSubject(relation string) *EventsHookAnnotation
EventsHookAdditionalSubject marks this field as a field to return as an additional subject
func EventsHookSubjectName ¶ added in v0.0.25
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.0.25
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 ¶ added in v0.0.25
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.0.25
func WithEventHooks() ExtensionOption
WithEventHooks adds the templates for generating event hooks
func WithFederation ¶ added in v0.0.25
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 ¶ added in v0.0.25
func WithJSONScalar() ExtensionOption
WithJSONScalar adds the JSON scalar definition
type TimestampsMixin ¶ added in v0.0.25
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 ¶ added in v0.0.25
func NewTimestampMixin() TimestampsMixin
NewTimestampMixin returns a Mixin that provides the created_at and updated_at timestamp fields