field

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const BuilderEditableContext = "builder"
View Source
const CreateEditableContext = "create"
View Source
const DeleteEditableContext = "delete"
View Source
const EditEditableContext = "edit"

Variables

This section is empty.

Functions

func CompareFieldInfo added in v0.0.38

func CompareFieldInfo(f1, f2 *FieldInfo) ([]change.Change, error)

func CompareNonEntField added in v0.0.38

func CompareNonEntField(existing, field *NonEntField) []change.Change

func FieldEqual added in v0.0.38

func FieldEqual(existing, field *Field) bool

func FieldsEqual added in v0.0.38

func FieldsEqual(fields1, fields2 []*Field) bool

func NonEntFieldEqual added in v0.0.38

func NonEntFieldEqual(existing, field *NonEntField) bool

func NonEntFieldsEqual added in v0.0.38

func NonEntFieldsEqual(existing, fields []*NonEntField) bool

func NormalizedField

func NormalizedField(s string) string

Types

type CustomInterfaceGetter added in v0.1.0

type CustomInterfaceGetter interface {
	GetCustomTypeByTSName(name string) CustomTypeWithHasConvertFunction
}

type CustomTypeWithHasConvertFunction added in v0.1.0

type CustomTypeWithHasConvertFunction interface {
	HasConvertFunction(cfg codegenapi.Config) bool
}

type EditableContext added in v0.1.0

type EditableContext string

type Field

type Field struct {
	// note that if this changes, need to update FieldEqual
	// todo: abstract out these 2 also...
	FieldName string
	// contains filtered or unexported fields
}

func NewFieldFromNameAndType added in v0.0.38

func NewFieldFromNameAndType(name string, typ enttype.TSType) *Field

mostly used by tests

func (*Field) AddFieldEdgeToEdgeInfo

func (f *Field) AddFieldEdgeToEdgeInfo(
	cfg codegenapi.Config,
	edgeInfo *edge.EdgeInfo,
	validSchema func(str string) bool,
) error

func (*Field) AddForeignKeyEdgeToInverseEdgeInfo

func (f *Field) AddForeignKeyEdgeToInverseEdgeInfo(
	cfg codegenapi.Config,
	edgeInfo *edge.EdgeInfo, nodeName string) error

func (*Field) AddForeignKeyFieldEdgeToEdgeInfo

func (f *Field) AddForeignKeyFieldEdgeToEdgeInfo(
	cfg codegenapi.Config,
	edgeInfo *edge.EdgeInfo,
	validSchema func(str string) bool,
) error

We're going from field -> edge to be consistent and not have circular dependencies

func (*Field) AddInverseEdge

func (f *Field) AddInverseEdge(cfg codegenapi.Config, edge *edge.AssociationEdge) error

func (*Field) CamelCaseName

func (f *Field) CamelCaseName() string

func (*Field) Clone

func (f *Field) Clone(opts ...Option) (*Field, error)

func (*Field) CreateDBColumn

func (f *Field) CreateDBColumn() bool

func (*Field) DefaultToViewerOnCreate added in v0.1.0

func (f *Field) DefaultToViewerOnCreate() bool

func (*Field) DefaultValue

func (f *Field) DefaultValue() *string

func (*Field) DisableUserGraphQLEditable added in v0.1.14

func (f *Field) DisableUserGraphQLEditable() bool

func (*Field) EditableField

func (f *Field) EditableField(ctx EditableContext) bool

create, delete, edit, builder TODO change everything to use this..

func (*Field) EditableGraphQLField added in v0.0.38

func (f *Field) EditableGraphQLField() bool

func (*Field) EmbeddableInParentAction

func (f *Field) EmbeddableInParentAction() bool

func (*Field) EvolvedIDField

func (f *Field) EvolvedIDField() bool

func (*Field) ExposeFieldOrFieldEdgeToGraphQL added in v0.1.0

func (f *Field) ExposeFieldOrFieldEdgeToGraphQL() bool

func (*Field) ExposeToActionsByDefault

func (f *Field) ExposeToActionsByDefault() bool

func (*Field) ExposeToGraphQL

func (f *Field) ExposeToGraphQL() bool

func (*Field) FetchOnDemand added in v0.1.0

func (f *Field) FetchOnDemand() bool

func (*Field) FetchOnLoad added in v0.1.0

func (f *Field) FetchOnLoad() bool

func (*Field) FieldEdgeInfo

func (f *Field) FieldEdgeInfo() *base.FieldEdgeInfo

func (*Field) ForceOptionalInAction

func (f *Field) ForceOptionalInAction() bool

func (*Field) ForceRequiredInAction

func (f *Field) ForceRequiredInAction() bool

func (*Field) ForeignKeyInfo

func (f *Field) ForeignKeyInfo() *ForeignKeyInfo

func (*Field) GetConvertImport added in v0.1.0

func (f *Field) GetConvertImport(cfg codegenapi.Config, g CustomInterfaceGetter) *tsimport.ImportPath

func (*Field) GetConvertMethod added in v0.1.0

func (f *Field) GetConvertMethod(cfg codegenapi.Config) string

func (*Field) GetDbColName

func (f *Field) GetDbColName() string

func (*Field) GetDbTypeForField

func (f *Field) GetDbTypeForField() string

func (*Field) GetFieldNameInStruct

func (f *Field) GetFieldNameInStruct() string

GetFieldNameInStruct returns the name of the field in the struct definition with capital letter for public fields. lowercase letter for package-private

func (*Field) GetFieldType

func (f *Field) GetFieldType() enttype.Type

func (*Field) GetGraphQLName

func (f *Field) GetGraphQLName() string

func (*Field) GetGraphQLTypeForField

func (f *Field) GetGraphQLTypeForField() string

func (*Field) GetImmutableOverrideFieldNameInBuilder added in v0.1.0

func (f *Field) GetImmutableOverrideFieldNameInBuilder() string

func (*Field) GetImportsForTypes added in v0.1.0

func (f *Field) GetImportsForTypes(cfg codegenapi.Config, g CustomInterfaceGetter, s enttype.SchemaType) []*tsimport.ImportPath

func (*Field) GetInverseEdge

func (f *Field) GetInverseEdge() *edge.AssociationEdge

func (*Field) GetNotNullableTsType

func (f *Field) GetNotNullableTsType() string

func (*Field) GetPatternName added in v0.0.37

func (f *Field) GetPatternName() string

func (*Field) GetPossibleTypes added in v0.1.0

func (f *Field) GetPossibleTypes() []enttype.Type

func (*Field) GetQuotedDBColName

func (f *Field) GetQuotedDBColName() string

func (*Field) GetTSFieldType added in v0.1.0

func (f *Field) GetTSFieldType(cfg codegenapi.Config) enttype.Type

should mirror TsFieldType because it's used to determine if nullable and if convertFunc

func (*Field) GetTSGraphQLTypeForFieldImports

func (f *Field) GetTSGraphQLTypeForFieldImports(input bool) []*tsimport.ImportPath

func (*Field) GetTSMutationGraphQLTypeForFieldImports added in v0.1.0

func (f *Field) GetTSMutationGraphQLTypeForFieldImports(forceOptional, input bool) []*tsimport.ImportPath

for non-required fields in actions, we want to make it optional if it's not a required field in the action in mutations, we ignore any graphql specific nature of the field and use underlying API TODO multiple booleans is a horrible code-smell. fix with options or something

func (*Field) GetTsType added in v0.0.39

func (f *Field) GetTsType() string

func (*Field) GetTsTypeImports added in v0.0.38

func (f *Field) GetTsTypeImports() []*tsimport.ImportPath

func (*Field) GetUserConvert added in v0.1.0

func (f *Field) GetUserConvert() *input.UserConvertType

func (*Field) HasAsyncAccessor added in v0.1.0

func (f *Field) HasAsyncAccessor(cfg codegenapi.Config) bool

func (*Field) HasConvertFunction added in v0.1.0

func (f *Field) HasConvertFunction(cfg codegenapi.Config, g CustomInterfaceGetter) bool

func (*Field) HasDefaultValueOnCreate

func (f *Field) HasDefaultValueOnCreate() bool

func (*Field) HasDefaultValueOnEdit

func (f *Field) HasDefaultValueOnEdit() bool

func (*Field) HasEditFieldPrivacy added in v0.1.0

func (f *Field) HasEditFieldPrivacy() bool

func (*Field) HasFieldPrivacy added in v0.1.0

func (f *Field) HasFieldPrivacy() bool

func (*Field) IDField

func (f *Field) IDField() bool

func (*Field) IDType added in v0.0.30

func (f *Field) IDType() bool

func (*Field) Index

func (f *Field) Index() bool

func (*Field) InstanceFieldName

func (f *Field) InstanceFieldName() string

func (*Field) IsEditableIDField

func (f *Field) IsEditableIDField(ctx EditableContext) bool

func (*Field) Nullable

func (f *Field) Nullable() bool

func (*Field) PatternField added in v0.0.37

func (f *Field) PatternField() bool

func (*Field) Private

func (f *Field) Private(cfg codegenapi.Config) bool

func (*Field) QueryFromEnt added in v0.0.32

func (f *Field) QueryFromEnt() bool

func (*Field) QueryFromEntName added in v0.0.32

func (f *Field) QueryFromEntName() string

func (*Field) SingleFieldPrimaryKey

func (f *Field) SingleFieldPrimaryKey() bool

func (*Field) TSBuilderWithRelativeType added in v0.1.0

func (f *Field) TSBuilderWithRelativeType(cfg codegenapi.Config) string

this assumes it's ok to do relative. up to caller to confirm that it is before calling

func (*Field) TSPublicAPIName added in v0.1.0

func (f *Field) TSPublicAPIName() string

either async function name or public field

func (*Field) TsActualType added in v0.1.0

func (f *Field) TsActualType() string

return type with no shenanigans

func (*Field) TsBuilderFieldName added in v0.1.0

func (f *Field) TsBuilderFieldName() string

func (*Field) TsBuilderImports

func (f *Field) TsBuilderImports(cfg codegenapi.Config) []*tsimport.ImportPath

func (*Field) TsBuilderType

func (f *Field) TsBuilderType(cfg codegenapi.Config) string

func (*Field) TsBuilderUnionType added in v0.1.0

func (f *Field) TsBuilderUnionType(cfg codegenapi.Config) string

for getFooValue() where there's a nullable type but the input type isn't nullable because the underlying db value isn't

func (*Field) TsFieldName

func (f *Field) TsFieldName(cfg codegenapi.Config) string

func (*Field) TsFieldType added in v0.1.0

func (f *Field) TsFieldType(cfg codegenapi.Config) string

type of the field in the class e.g. readonly name type;

func (*Field) TsType

func (f *Field) TsType() string

func (*Field) Unique

func (f *Field) Unique() bool

type FieldInfo

type FieldInfo struct {

	// really only used in tests and old go schema
	NonEntFields []*NonEntField
	// contains filtered or unexported fields
}

func NewFieldInfoFromInputs

func NewFieldInfoFromInputs(cfg codegenapi.Config, nodeName string, fields []*input.Field, options *Options) (*FieldInfo, error)

func (*FieldInfo) AddComputedField added in v0.0.39

func (fieldInfo *FieldInfo) AddComputedField(f string) error

func (*FieldInfo) AllFields added in v0.1.0

func (fieldInfo *FieldInfo) AllFields() []*Field

func (*FieldInfo) EntFields added in v0.1.0

func (fieldInfo *FieldInfo) EntFields() []*Field

func (*FieldInfo) GetEditableFieldsInBuilder added in v0.1.0

func (fieldInfo *FieldInfo) GetEditableFieldsInBuilder() []*Field

need a difference btw builder fields, create-only fields etc basically need to special case create and add it in creation and then overrideFoo(val) etc...

func (*FieldInfo) GetFieldByColName

func (fieldInfo *FieldInfo) GetFieldByColName(col string) *Field

func (*FieldInfo) GetFieldByName

func (fieldInfo *FieldInfo) GetFieldByName(fieldName string) *Field

func (*FieldInfo) GetImmutableFields added in v0.1.0

func (fieldInfo *FieldInfo) GetImmutableFields() []*Field

func (*FieldInfo) GraphQLFields

func (fieldInfo *FieldInfo) GraphQLFields() []*Field

func (*FieldInfo) InvalidateFieldForGraphQL

func (fieldInfo *FieldInfo) InvalidateFieldForGraphQL(f *Field) error

func (*FieldInfo) IsComputedField added in v0.0.39

func (fieldInfo *FieldInfo) IsComputedField(f string) bool

func (*FieldInfo) NotEditableInverseEdgeFieldsWithDefaults added in v0.1.0

func (fieldInfo *FieldInfo) NotEditableInverseEdgeFieldsWithDefaults() []*Field

should be only used in builder

func (*FieldInfo) SingleFieldPrimaryKey added in v0.1.0

func (fieldInfo *FieldInfo) SingleFieldPrimaryKey() string

type ForeignKeyInfo

type ForeignKeyInfo struct {
	// Note that changing this should update foreignKeyInfoEqual
	Schema       string
	Field        string
	Name         string
	DisableIndex bool
}

ForeignKeyInfo stores config and field name of the foreign key object

type NonEntField

type NonEntField struct {

	// TODO these are both go things. ignore
	// Flag enum or ID
	Flag string
	// this is a go-thing. ignore for TypeScript
	NodeType string
	// contains filtered or unexported fields
}

func NewNonEntField added in v0.0.37

func NewNonEntField(cfg codegenapi.Config, fieldName string, fieldType enttype.TSType, nullable, hideFromGraphQL bool) *NonEntField

func (*NonEntField) DefaultValue added in v0.0.37

func (f *NonEntField) DefaultValue() *string

func (*NonEntField) ExposeToGraphQL added in v0.1.0

func (f *NonEntField) ExposeToGraphQL() bool

func (*NonEntField) ForceOptionalInAction added in v0.0.37

func (f *NonEntField) ForceOptionalInAction() bool

func (*NonEntField) ForceRequiredInAction added in v0.0.37

func (f *NonEntField) ForceRequiredInAction() bool

func (*NonEntField) GetFieldName added in v0.0.39

func (f *NonEntField) GetFieldName() string

func (*NonEntField) GetFieldType added in v0.0.37

func (f *NonEntField) GetFieldType() enttype.Type

func (*NonEntField) GetGraphQLFieldType added in v0.0.39

func (f *NonEntField) GetGraphQLFieldType() enttype.TSType

func (*NonEntField) GetGraphQLMutationFieldType added in v0.1.0

func (f *NonEntField) GetGraphQLMutationFieldType(forceOptional bool) enttype.TSType

func (*NonEntField) GetGraphQLName

func (f *NonEntField) GetGraphQLName() string

func (*NonEntField) GetTSGraphQLTypeForFieldImports added in v0.1.0

func (f *NonEntField) GetTSGraphQLTypeForFieldImports(input bool) []*tsimport.ImportPath

func (*NonEntField) GetTsType added in v0.0.37

func (f *NonEntField) GetTsType() string

don't have to deal with all the id field stuff field.Field has to deal with

func (*NonEntField) GetTsTypeImports added in v0.0.39

func (f *NonEntField) GetTsTypeImports() []*tsimport.ImportPath

func (*NonEntField) HasDefaultValueOnCreate added in v0.0.37

func (f *NonEntField) HasDefaultValueOnCreate() bool

func (*NonEntField) IsEditableIDField added in v0.0.39

func (f *NonEntField) IsEditableIDField(ctx EditableContext) bool

func (*NonEntField) Nullable added in v0.0.37

func (f *NonEntField) Nullable() bool

func (*NonEntField) Optional added in v0.1.0

func (f *NonEntField) Optional() bool

func (*NonEntField) Required added in v0.0.37

func (f *NonEntField) Required() bool

func (*NonEntField) SetFlag added in v0.0.39

func (f *NonEntField) SetFlag(flag string) *NonEntField

func (*NonEntField) SetNodeType added in v0.0.39

func (f *NonEntField) SetNodeType(nodeType string) *NonEntField

func (*NonEntField) SetOptional added in v0.1.0

func (f *NonEntField) SetOptional(optional bool) *NonEntField

func (*NonEntField) SingleFieldPrimaryKey added in v0.1.13

func (f *NonEntField) SingleFieldPrimaryKey() bool

func (*NonEntField) TSPublicAPIName added in v0.1.0

func (f *NonEntField) TSPublicAPIName() string

func (*NonEntField) TsBuilderFieldName added in v0.1.0

func (f *NonEntField) TsBuilderFieldName() string

func (*NonEntField) TsBuilderType added in v0.1.0

func (f *NonEntField) TsBuilderType(cfg codegenapi.Config) string

func (*NonEntField) TsFieldName added in v0.0.37

func (f *NonEntField) TsFieldName(cfg codegenapi.Config) string

type Option

type Option func(*Field)

func Nullable added in v0.1.12

func Nullable() Option

func Optional

func Optional() Option

func Required

func Required() Option

type Options

type Options struct {
	SortFields     bool
	FieldOverrides map[string]*input.FieldOverride
}

Jump to

Keyboard shortcuts

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