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") // PubsubHooksTemplate adds support for generating pubsub hooks PubsubHooksTemplate = parseT("template/pubsub_hooks.tmpl") // TemplateFuncs contains the extra template functions used by entx. TemplateFuncs = template.FuncMap{ "contains": strings.Contains, } )
var PubsubAnnotationName = "INFRA9_PUBSUBHOOK"
PubsubAnnotationName 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 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
func WithPubsubHooks ¶ added in v0.1.0
func WithPubsubHooks() ExtensionOption
WithPubsubHooks adds the templates for generating pubsub hooks
type PubsubAnnotation ¶ added in v0.1.0
PubsubAnnotation provides a ent.Annotation spec. These shouldn't be set directly, you should use PubsubAdditionalSubject() and PubsubSubjectName instead
func PubsubAdditionalSubject ¶ added in v0.1.0
func PubsubAdditionalSubject() *PubsubAnnotation
PubsubAdditionalSubject marks this field as a field to return as an additional subject
func PubsubSubjectName ¶ added in v0.1.0
func PubsubSubjectName(s string) *PubsubAnnotation
PubsubSubjectName sets the subject name that is where the messages for this object will be sent
func (PubsubAnnotation) Name ¶ added in v0.1.0
func (a PubsubAnnotation) Name() string
Name implements the ent Annotation interface.
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