action

package
v0.0.38-alpha1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const NO_FIELDS = "__NO_FIELDS__"

provides a way to say this action doesn't have any fields

Variables

This section is empty.

Functions

func GetActionMethodName

func GetActionMethodName(action Action) (string, error)

func HasInput

func HasInput(action Action) bool

func HasOnlyActionOnlyFields

func HasOnlyActionOnlyFields(action Action) bool

func IsEdgeAction

func IsEdgeAction(action Action) bool

func IsEdgeGroupAction

func IsEdgeGroupAction(action Action) bool

func IsRemoveEdgeAction

func IsRemoveEdgeAction(action Action) bool

func IsRequiredField

func IsRequiredField(action Action, field ActionField) bool

Types

type Action

type Action interface {
	GetFields() []*field.Field
	GetNonEntFields() []*field.NonEntField
	GetEdges() []*edge.AssociationEdge
	GetEdgeGroup() *edge.AssociationEdgeGroup
	GetActionName() string
	ExposedToGraphQL() bool
	GetGraphQLName() string
	GetInputName() string         // only applies in TypeScript?
	MutatingExistingObject() bool // whether to add User, Note etc params
	GetNodeInfo() nodeinfo.NodeInfo
	GetOperation() ent.ActionOperation
	IsDeletingNode() bool
	AddCustomField(enttype.TSGraphQLType, *field.Field)
	AddCustomNonEntField(enttype.TSGraphQLType, *field.NonEntField)
	AddCustomInterfaces(a Action)
	GetCustomInterfaces() []*custominterface.CustomInterface
	GetTSEnums() []*enum.Enum
	GetGQLEnums() []*enum.GQLEnum
}

type ActionField added in v0.0.35

type ActionField interface {
	GetFieldType() enttype.EntType
	TsFieldName() string
	GetGraphQLName() string
	ForceRequiredInAction() bool
	ForceOptionalInAction() bool
	DefaultValue() interface{}
	Nullable() bool
	HasDefaultValueOnCreate() bool
}

type ActionInfo

type ActionInfo struct {
	Actions []Action
	// contains filtered or unexported fields
}

func NewActionInfo

func NewActionInfo() *ActionInfo

func ParseActions

func ParseActions(nodeName string, fn *ast.FuncDecl, fieldInfo *field.FieldInfo, edgeInfo *edge.EdgeInfo, lang base.Language) (*ActionInfo, error)

func ParseFromInput

func ParseFromInput(nodeName string, actions []*input.Action, fieldInfo *field.FieldInfo, edgeInfo *edge.EdgeInfo, lang base.Language) (*ActionInfo, error)

func (*ActionInfo) GetByGraphQLName

func (info *ActionInfo) GetByGraphQLName(name string) Action

func (*ActionInfo) GetByName

func (info *ActionInfo) GetByName(name string) Action

type AddEdgeAction

type AddEdgeAction struct {
	// contains filtered or unexported fields
}

func (*AddEdgeAction) AddCustomField

func (action *AddEdgeAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*AddEdgeAction) AddCustomInterfaces

func (action *AddEdgeAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*AddEdgeAction) AddCustomNonEntField

func (action *AddEdgeAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*AddEdgeAction) ExposedToGraphQL

func (action *AddEdgeAction) ExposedToGraphQL() bool

func (*AddEdgeAction) GetActionName

func (action *AddEdgeAction) GetActionName() string

func (*AddEdgeAction) GetCustomInterfaces

func (action *AddEdgeAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*AddEdgeAction) GetEdgeGroup

func (action *AddEdgeAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*AddEdgeAction) GetEdges

func (action *AddEdgeAction) GetEdges() []*edge.AssociationEdge

func (*AddEdgeAction) GetFields

func (action *AddEdgeAction) GetFields() []*field.Field

func (*AddEdgeAction) GetGQLEnums

func (action *AddEdgeAction) GetGQLEnums() []*enum.GQLEnum

func (*AddEdgeAction) GetGraphQLName

func (action *AddEdgeAction) GetGraphQLName() string

func (*AddEdgeAction) GetInputName

func (action *AddEdgeAction) GetInputName() string

func (*AddEdgeAction) GetNodeInfo

func (action *AddEdgeAction) GetNodeInfo() nodeinfo.NodeInfo

func (*AddEdgeAction) GetNonEntFields

func (action *AddEdgeAction) GetNonEntFields() []*field.NonEntField

func (*AddEdgeAction) GetOperation

func (action *AddEdgeAction) GetOperation() ent.ActionOperation

func (*AddEdgeAction) GetTSEnums

func (action *AddEdgeAction) GetTSEnums() []*enum.Enum

func (*AddEdgeAction) IsDeletingNode

func (action *AddEdgeAction) IsDeletingNode() bool

func (*AddEdgeAction) MutatingExistingObject

func (action *AddEdgeAction) MutatingExistingObject() bool

type CreateAction

type CreateAction struct {
	// contains filtered or unexported fields
}

func (*CreateAction) AddCustomField

func (action *CreateAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*CreateAction) AddCustomInterfaces

func (action *CreateAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*CreateAction) AddCustomNonEntField

func (action *CreateAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*CreateAction) ExposedToGraphQL

func (action *CreateAction) ExposedToGraphQL() bool

func (*CreateAction) GetActionName

func (action *CreateAction) GetActionName() string

func (*CreateAction) GetCustomInterfaces

func (action *CreateAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*CreateAction) GetEdgeGroup

func (action *CreateAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*CreateAction) GetEdges

func (action *CreateAction) GetEdges() []*edge.AssociationEdge

func (*CreateAction) GetFields

func (action *CreateAction) GetFields() []*field.Field

func (*CreateAction) GetGQLEnums

func (action *CreateAction) GetGQLEnums() []*enum.GQLEnum

func (*CreateAction) GetGraphQLName

func (action *CreateAction) GetGraphQLName() string

func (*CreateAction) GetInputName

func (action *CreateAction) GetInputName() string

func (*CreateAction) GetNodeInfo

func (action *CreateAction) GetNodeInfo() nodeinfo.NodeInfo

func (*CreateAction) GetNonEntFields

func (action *CreateAction) GetNonEntFields() []*field.NonEntField

func (*CreateAction) GetOperation

func (action *CreateAction) GetOperation() ent.ActionOperation

func (*CreateAction) GetTSEnums

func (action *CreateAction) GetTSEnums() []*enum.Enum

func (*CreateAction) IsDeletingNode

func (action *CreateAction) IsDeletingNode() bool

func (*CreateAction) MutatingExistingObject

func (action *CreateAction) MutatingExistingObject() bool

type DeleteAction

type DeleteAction struct {
	// contains filtered or unexported fields
}

func (*DeleteAction) AddCustomField

func (action *DeleteAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*DeleteAction) AddCustomInterfaces

func (action *DeleteAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*DeleteAction) AddCustomNonEntField

func (action *DeleteAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*DeleteAction) ExposedToGraphQL

func (action *DeleteAction) ExposedToGraphQL() bool

func (*DeleteAction) GetActionName

func (action *DeleteAction) GetActionName() string

func (*DeleteAction) GetCustomInterfaces

func (action *DeleteAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*DeleteAction) GetEdgeGroup

func (action *DeleteAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*DeleteAction) GetEdges

func (action *DeleteAction) GetEdges() []*edge.AssociationEdge

func (*DeleteAction) GetFields

func (action *DeleteAction) GetFields() []*field.Field

func (*DeleteAction) GetGQLEnums

func (action *DeleteAction) GetGQLEnums() []*enum.GQLEnum

func (*DeleteAction) GetGraphQLName

func (action *DeleteAction) GetGraphQLName() string

func (*DeleteAction) GetInputName

func (action *DeleteAction) GetInputName() string

func (*DeleteAction) GetNodeInfo

func (action *DeleteAction) GetNodeInfo() nodeinfo.NodeInfo

func (*DeleteAction) GetNonEntFields

func (action *DeleteAction) GetNonEntFields() []*field.NonEntField

func (*DeleteAction) GetOperation

func (action *DeleteAction) GetOperation() ent.ActionOperation

func (*DeleteAction) GetTSEnums

func (action *DeleteAction) GetTSEnums() []*enum.Enum

func (*DeleteAction) IsDeletingNode

func (action *DeleteAction) IsDeletingNode() bool

func (*DeleteAction) MutatingExistingObject

func (action *DeleteAction) MutatingExistingObject() bool

type EdgeActionTemplateInfo

type EdgeActionTemplateInfo struct {
	AddEntMethodName         string
	AddSingleIDMethodName    string
	AddMultiIDMethodName     string
	RemoveEntMethodName      string
	RemoveSingleIDMethodName string
	RemoveMultiIDMethodName  string
	EdgeName                 string
	InstanceName             string
	InstanceType             string
	//	AssocEdge    *edge.AssociationEdge
	EdgeConst          string
	NodeType           string
	Node               string
	GraphQLNodeID      string
	TSEdgeConst        string
	TSGraphQLNodeID    string
	TSAddMethodName    string
	TSAddIDMethodName  string
	TSRemoveMethodName string
	Edge               edge.Edge
}

func GetEdges

func GetEdges(action Action) []EdgeActionTemplateInfo

func GetEdgesFromEdges

func GetEdgesFromEdges(edges []*edge.AssociationEdge) []EdgeActionTemplateInfo

ALso TODO...

type EdgeGroupAction

type EdgeGroupAction struct {
	// contains filtered or unexported fields
}

func (*EdgeGroupAction) AddCustomField

func (action *EdgeGroupAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*EdgeGroupAction) AddCustomInterfaces

func (action *EdgeGroupAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*EdgeGroupAction) AddCustomNonEntField

func (action *EdgeGroupAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*EdgeGroupAction) ExposedToGraphQL

func (action *EdgeGroupAction) ExposedToGraphQL() bool

func (*EdgeGroupAction) GetActionName

func (action *EdgeGroupAction) GetActionName() string

func (*EdgeGroupAction) GetCustomInterfaces

func (action *EdgeGroupAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*EdgeGroupAction) GetEdgeGroup

func (action *EdgeGroupAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*EdgeGroupAction) GetEdges

func (action *EdgeGroupAction) GetEdges() []*edge.AssociationEdge

func (*EdgeGroupAction) GetFields

func (action *EdgeGroupAction) GetFields() []*field.Field

func (*EdgeGroupAction) GetGQLEnums

func (action *EdgeGroupAction) GetGQLEnums() []*enum.GQLEnum

func (*EdgeGroupAction) GetGraphQLName

func (action *EdgeGroupAction) GetGraphQLName() string

func (*EdgeGroupAction) GetInputName

func (action *EdgeGroupAction) GetInputName() string

func (*EdgeGroupAction) GetNodeInfo

func (action *EdgeGroupAction) GetNodeInfo() nodeinfo.NodeInfo

func (*EdgeGroupAction) GetNonEntFields

func (action *EdgeGroupAction) GetNonEntFields() []*field.NonEntField

func (*EdgeGroupAction) GetOperation

func (action *EdgeGroupAction) GetOperation() ent.ActionOperation

func (*EdgeGroupAction) GetTSEnums

func (action *EdgeGroupAction) GetTSEnums() []*enum.Enum

func (*EdgeGroupAction) IsDeletingNode

func (action *EdgeGroupAction) IsDeletingNode() bool

func (*EdgeGroupAction) MutatingExistingObject

func (action *EdgeGroupAction) MutatingExistingObject() bool

type EditAction

type EditAction struct {
	// contains filtered or unexported fields
}

func (*EditAction) AddCustomField

func (action *EditAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*EditAction) AddCustomInterfaces

func (action *EditAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*EditAction) AddCustomNonEntField

func (action *EditAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*EditAction) ExposedToGraphQL

func (action *EditAction) ExposedToGraphQL() bool

func (*EditAction) GetActionName

func (action *EditAction) GetActionName() string

func (*EditAction) GetCustomInterfaces

func (action *EditAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*EditAction) GetEdgeGroup

func (action *EditAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*EditAction) GetEdges

func (action *EditAction) GetEdges() []*edge.AssociationEdge

func (*EditAction) GetFields

func (action *EditAction) GetFields() []*field.Field

func (*EditAction) GetGQLEnums

func (action *EditAction) GetGQLEnums() []*enum.GQLEnum

func (*EditAction) GetGraphQLName

func (action *EditAction) GetGraphQLName() string

func (*EditAction) GetInputName

func (action *EditAction) GetInputName() string

func (*EditAction) GetNodeInfo

func (action *EditAction) GetNodeInfo() nodeinfo.NodeInfo

func (*EditAction) GetNonEntFields

func (action *EditAction) GetNonEntFields() []*field.NonEntField

func (*EditAction) GetOperation

func (action *EditAction) GetOperation() ent.ActionOperation

func (*EditAction) GetTSEnums

func (action *EditAction) GetTSEnums() []*enum.Enum

func (*EditAction) IsDeletingNode

func (action *EditAction) IsDeletingNode() bool

func (*EditAction) MutatingExistingObject

func (action *EditAction) MutatingExistingObject() bool

type FieldActionTemplateInfo

type FieldActionTemplateInfo struct {
	SetterMethodName         string
	NullableSetterMethodName string
	GetterMethodName         string
	InstanceName             string
	InstanceType             string
	FieldKey                 string
	FieldName                string
	QuotedFieldName          string
	QuotedDBName             string
	InverseEdge              *edge.AssociationEdge
	IsStatusEnum             bool
	IsGroupID                bool
	NodeType                 string
	Field                    *field.Field
}

FieldActionTemplateInfo is passed to codegeneration template (both action and graphql) to generate the code needed for actions

func GetFields

func GetFields(action Action) []FieldActionTemplateInfo

func GetFieldsFromFields

func GetFieldsFromFields(fields []*field.Field) []FieldActionTemplateInfo

TODO abstract this out somewhere else...

func GetNonEntFields

func GetNonEntFields(action Action) []FieldActionTemplateInfo

type RemoveEdgeAction

type RemoveEdgeAction struct {
	// contains filtered or unexported fields
}

func (*RemoveEdgeAction) AddCustomField

func (action *RemoveEdgeAction) AddCustomField(typ enttype.TSGraphQLType, cf *field.Field)

func (*RemoveEdgeAction) AddCustomInterfaces

func (action *RemoveEdgeAction) AddCustomInterfaces(a2 Action)

Unclear what the best solution is here but the decision here is to create (duplicate) a private interface in the action that represents the input but in GraphQL we import the existing one since GraphQL names are unique across the types and we don't crazy naming conflicts in here we can (and should?) probably namespace the private generated interface name by adding a new prefix but no conflicts yet so leaving it for now This choice isn't consistent but is the easiest path so doing that

func (*RemoveEdgeAction) AddCustomNonEntField

func (action *RemoveEdgeAction) AddCustomNonEntField(typ enttype.TSGraphQLType, cf *field.NonEntField)

func (*RemoveEdgeAction) ExposedToGraphQL

func (action *RemoveEdgeAction) ExposedToGraphQL() bool

func (*RemoveEdgeAction) GetActionName

func (action *RemoveEdgeAction) GetActionName() string

func (*RemoveEdgeAction) GetCustomInterfaces

func (action *RemoveEdgeAction) GetCustomInterfaces() []*custominterface.CustomInterface

func (*RemoveEdgeAction) GetEdgeGroup

func (action *RemoveEdgeAction) GetEdgeGroup() *edge.AssociationEdgeGroup

func (*RemoveEdgeAction) GetEdges

func (action *RemoveEdgeAction) GetEdges() []*edge.AssociationEdge

func (*RemoveEdgeAction) GetFields

func (action *RemoveEdgeAction) GetFields() []*field.Field

func (*RemoveEdgeAction) GetGQLEnums

func (action *RemoveEdgeAction) GetGQLEnums() []*enum.GQLEnum

func (*RemoveEdgeAction) GetGraphQLName

func (action *RemoveEdgeAction) GetGraphQLName() string

func (*RemoveEdgeAction) GetInputName

func (action *RemoveEdgeAction) GetInputName() string

func (*RemoveEdgeAction) GetNodeInfo

func (action *RemoveEdgeAction) GetNodeInfo() nodeinfo.NodeInfo

func (*RemoveEdgeAction) GetNonEntFields

func (action *RemoveEdgeAction) GetNonEntFields() []*field.NonEntField

func (*RemoveEdgeAction) GetOperation

func (action *RemoveEdgeAction) GetOperation() ent.ActionOperation

func (*RemoveEdgeAction) GetTSEnums

func (action *RemoveEdgeAction) GetTSEnums() []*enum.Enum

func (*RemoveEdgeAction) IsDeletingNode

func (action *RemoveEdgeAction) IsDeletingNode() bool

func (*RemoveEdgeAction) MutatingExistingObject

func (action *RemoveEdgeAction) MutatingExistingObject() bool

Jump to

Keyboard shortcuts

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