Documentation
¶
Overview ¶
* @Author: Marlon.M * @Email: maiguangyang@163.com * @Date: 2025-12-22 13:38:16
Index ¶
- Constants
- Variables
- func All[T any](items []T, predicate func(T) bool) bool
- func Any[T any](items []T, predicate func(T) bool) bool
- func EnrichModel(m *Model) error
- func EnrichModelObjects(m *Model) error
- func Filter[T any](items []T, predicate func(T) bool) []T
- func Find[T any](items []T, predicate func(T) bool) (T, bool)
- func GetRandomString(n int) string
- func IndexOf[T comparable](slice []T, item T) int
- func Map[T any, R any](items []T, transform func(T) R) []R
- func PrintSchema(model Model) (string, error)
- func RegexpReplace(str, start string, end string) string
- type Config
- type FilterMappingItem
- type Model
- func (m *Model) HasEnum(name string) bool
- func (m *Model) HasFederatedTypes() bool
- func (m *Model) HasObject(name string) bool
- func (m *Model) HasObjectExtension(name string) bool
- func (m *Model) HasScalar(name string) bool
- func (m *Model) Object(name string) Object
- func (m *Model) ObjectEntities() []Object
- func (m *Model) ObjectExtension(name string) ObjectExtension
- func (m *Model) ObjectExtensions() []ObjectExtension
- func (m *Model) ObjectShardings() []Object
- func (m *Model) Objects() []Object
- func (m *Model) SecretKey() string
- type Object
- func (o *Object) Column(name string) *ObjectField
- func (o *Object) Columns() []ObjectField
- func (o *Object) Directive(name string) *ast.Directive
- func (o *Object) EntityName() string
- func (o *Object) Field(name string) *ObjectField
- func (o *Object) Fields() []ObjectField
- func (o *Object) HasAnyRelationships() bool
- func (o *Object) HasColumn(name string) bool
- func (o *Object) HasDirective(name string) bool
- func (o *Object) HasEmbeddedField() bool
- func (o *Object) HasField(name string) bool
- func (o *Object) HasPreloadableRelationships() bool
- func (o *Object) HasRelationship(name string) bool
- func (o *Object) Interfaces() []string
- func (o *Object) IsExtended() bool
- func (o *Object) IsFederatedType() bool
- func (o *Object) IsSharding() bool
- func (o *Object) IsSkip() bool
- func (o *Object) IsToManyColumn(c ObjectField) bool
- func (o *Object) LowerName() string
- func (o *Object) Name() string
- func (o *Object) NeedsQueryResolver() bool
- func (o *Object) PluralName() string
- func (o *Object) PreloadableRelationships() []*ObjectRelationship
- func (o *Object) Relationship(name string) *ObjectRelationship
- func (o *Object) Relationships() []*ObjectRelationship
- func (o *Object) TableName() string
- func (o *Object) ToCamel() string
- func (o *Object) ToLowerPluralName() string
- func (o *Object) ToSnakeName() string
- func (o *Object) ToSnakePluraName() string
- type ObjectExtension
- type ObjectField
- func (o *ObjectField) Arguments() string
- func (o *ObjectField) ArgumentsValue() []ObjectFieldInput
- func (o *ObjectField) ColumnType() (value string)
- func (o *ObjectField) Directive(name string) *ast.Directive
- func (o *ObjectField) EntityName() string
- func (o *ObjectField) FilterMapping() []FilterMappingItem
- func (o *ObjectField) GetArgValue(name string) map[string]map[string]string
- func (o *ObjectField) GetComment() string
- func (o *ObjectField) GetDefault() string
- func (o *ObjectField) GetRemark() string
- func (o *ObjectField) GetTableName() string
- func (o *ObjectField) GetType() string
- func (o *ObjectField) GetValidator() string
- func (o *ObjectField) GoType() string
- func (o *ObjectField) GoTypeWithPointer() string
- func (o *ObjectField) HasDirective(name string) bool
- func (o *ObjectField) HasName(name string) bool
- func (o *ObjectField) HasTargetObject() bool
- func (o *ObjectField) HasTargetObjectExtension() bool
- func (o *ObjectField) HasTargetTypeWithIDField() bool
- func (o *ObjectField) InputType() ast.Type
- func (o *ObjectField) Inputs() string
- func (o *ObjectField) IsColumn() bool
- func (o *ObjectField) IsCreataDocs() bool
- func (o *ObjectField) IsCreatable() bool
- func (o *ObjectField) IsEmbedded() bool
- func (o *ObjectField) IsEmbeddedColumn() bool
- func (o *ObjectField) IsEnumType() bool
- func (o *ObjectField) IsHasUpperId() bool
- func (o *ObjectField) IsID() bool
- func (o *ObjectField) IsIdentifier() bool
- func (o *ObjectField) IsInt() bool
- func (o *ObjectField) IsList() bool
- func (o *ObjectField) IsListType() bool
- func (o *ObjectField) IsOptional() bool
- func (o *ObjectField) IsReadonlyType() bool
- func (o *ObjectField) IsRelationship() bool
- func (o *ObjectField) IsRelationshipIdentifier() bool
- func (o *ObjectField) IsRelationshipRequired() bool
- func (o *ObjectField) IsRequired() bool
- func (o *ObjectField) IsScalarType() bool
- func (o *ObjectField) IsSearchable() bool
- func (o *ObjectField) IsShardingID() bool
- func (o *ObjectField) IsSortable() bool
- func (o *ObjectField) IsString() bool
- func (o *ObjectField) IsUpdatable() bool
- func (o *ObjectField) IsWritableType() bool
- func (o *ObjectField) LowerName() string
- func (o *ObjectField) MethodName() string
- func (o *ObjectField) ModelTags() string
- func (o *ObjectField) Name() string
- func (o *ObjectField) NeedsQueryResolver() bool
- func (o *ObjectField) RelationshipName() string
- func (o *ObjectField) RelationshipTypeName() string
- func (o *ObjectField) TargetObject() *Object
- func (o *ObjectField) TargetObjectExtension() *ObjectExtension
- func (o *ObjectField) TargetType() string
- func (o *ObjectField) ToSnakeName() string
- func (o *ObjectField) Type() string
- type ObjectFieldInput
- type ObjectRelationship
- func (o *ObjectRelationship) BoolForRelationshipDirectiveAttribute(name string) (val bool, ok bool)
- func (o *ObjectRelationship) ChangesName() string
- func (o *ObjectRelationship) ChangesType() string
- func (o *ObjectRelationship) GoType() string
- func (o *ObjectRelationship) InverseRelationship() *ObjectRelationship
- func (o *ObjectRelationship) InverseRelationshipName() string
- func (o *ObjectRelationship) IsDelete() bool
- func (o *ObjectRelationship) IsMainRelationshipForManyToMany() bool
- func (o *ObjectRelationship) IsManyToMany() bool
- func (o *ObjectRelationship) IsManyToOne() bool
- func (o *ObjectRelationship) IsMaster() bool
- func (o *ObjectRelationship) IsNonNull() bool
- func (o *ObjectRelationship) IsOneToMany() bool
- func (o *ObjectRelationship) IsOneToOne() bool
- func (o *ObjectRelationship) IsSelfReferencing() bool
- func (o *ObjectRelationship) IsToMany() bool
- func (o *ObjectRelationship) IsToOne() bool
- func (o *ObjectRelationship) JoinString() string
- func (o *ObjectRelationship) LowerName() string
- func (o *ObjectRelationship) MainRelationshipForManyToMany() *ObjectRelationship
- func (o *ObjectRelationship) ManyToManyJoinTable() string
- func (o *ObjectRelationship) MethodName() string
- func (o *ObjectRelationship) ModelTags() string
- func (o *ObjectRelationship) Name() string
- func (o *ObjectRelationship) Preload() bool
- func (o *ObjectRelationship) ReturnType() string
- func (o *ObjectRelationship) StringForRelationshipDirectiveAttribute(name string) (val string, ok bool)
- func (o *ObjectRelationship) Target() *Object
- func (o *ObjectRelationship) TargetType() string
- func (o *ObjectRelationship) TargetTypeToSnakeName() string
- func (o *ObjectRelationship) ToSnakeName() string
- func (o *ObjectRelationship) ToSnakeRelationshipName() string
- func (o *ObjectRelationship) UpperRelationshipName() string
- func (o *ObjectRelationship) ValueForRelationshipDirectiveAttribute(name string) (val interface{}, ok bool)
Constants ¶
const ( CREATE string = "Create" UPDATE string = "Update" )
Variables ¶
var YmlFileName = "dolphin.yml"
Functions ¶
func GetRandomString ¶
func IndexOf ¶
func IndexOf[T comparable](slice []T, item T) int
IndexOf returns the index of item in slice, or -1 if not found.
func RegexpReplace ¶
RegexpReplace 正则截取:提取 start 和 end 之间的内容
Types ¶
type Config ¶
type Config struct {
Package string `json:"package"`
Connection *struct {
MaxIdleConnections *uint `json:"maxIdleConnections"`
ConnMaxLifetime *string `json:"connMaxLifetime"`
MaxOpenConnections *uint `json:"maxOpenConnections"`
} `json:"connection,omitempty"`
}
func LoadConfig ¶
func LoadConfigFromPath ¶
func (*Config) ConnMaxLifetime ¶
func (*Config) MaxIdleConnections ¶
func (*Config) MaxOpenConnections ¶
type FilterMappingItem ¶
type FilterMappingItem struct {
Suffix string
Operator string
InputType ast.Type
ValueFormat string
}
FilterMappingItem 表示过滤器映射项
func (*FilterMappingItem) SuffixCamel ¶
func (f *FilterMappingItem) SuffixCamel() string
SuffixCamel 返回后缀的驼峰形式
func (*FilterMappingItem) WrapValueVariable ¶
func (f *FilterMappingItem) WrapValueVariable(v string) string
WrapValueVariable 用格式包装值变量
type Model ¶
func (*Model) HasFederatedTypes ¶
func (*Model) HasObjectExtension ¶
func (*Model) ObjectEntities ¶
func (*Model) ObjectExtension ¶
func (m *Model) ObjectExtension(name string) ObjectExtension
func (*Model) ObjectExtensions ¶
func (m *Model) ObjectExtensions() []ObjectExtension
func (*Model) ObjectShardings ¶
type Object ¶
type Object struct {
Def *ast.ObjectDefinition
Model *Model
Extension *ObjectExtension
}
func (*Object) Column ¶
func (o *Object) Column(name string) *ObjectField
func (*Object) EntityName ¶
func (*Object) Field ¶
func (o *Object) Field(name string) *ObjectField
func (*Object) HasAnyRelationships ¶
func (*Object) HasDirective ¶
func (*Object) HasEmbeddedField ¶
func (*Object) HasPreloadableRelationships ¶
func (*Object) HasRelationship ¶
func (*Object) Interfaces ¶
func (*Object) IsExtended ¶
func (*Object) IsFederatedType ¶
func (*Object) IsSharding ¶
func (*Object) IsToManyColumn ¶
func (o *Object) IsToManyColumn(c ObjectField) bool
func (*Object) NeedsQueryResolver ¶
func (*Object) PluralName ¶
func (*Object) PreloadableRelationships ¶
func (o *Object) PreloadableRelationships() []*ObjectRelationship
func (*Object) Relationship ¶
func (o *Object) Relationship(name string) *ObjectRelationship
func (*Object) Relationships ¶
func (o *Object) Relationships() []*ObjectRelationship
func (*Object) ToLowerPluralName ¶
func (*Object) ToSnakeName ¶
func (*Object) ToSnakePluraName ¶
type ObjectExtension ¶
type ObjectExtension struct {
Def *ast.TypeExtensionDefinition
Model *Model
Object *Object
}
func (*ObjectExtension) ExtendsLocalObject ¶
func (oe *ObjectExtension) ExtendsLocalObject() bool
func (*ObjectExtension) IsFederatedType ¶
func (oe *ObjectExtension) IsFederatedType() bool
type ObjectField ¶
type ObjectField struct {
Def *ast.FieldDefinition
Obj *Object
}
ObjectField 表示 GraphQL 对象的一个字段
func (*ObjectField) Arguments ¶
func (o *ObjectField) Arguments() string
Arguments 返回格式化的 GraphQL 参数字符串
func (*ObjectField) ArgumentsValue ¶
func (o *ObjectField) ArgumentsValue() []ObjectFieldInput
ArgumentsValue 返回字段的参数列表
func (*ObjectField) Directive ¶
func (o *ObjectField) Directive(name string) *ast.Directive
Directive 获取字段上的指定指令
func (*ObjectField) FilterMapping ¶
func (o *ObjectField) FilterMapping() []FilterMappingItem
FilterMapping 返回字段的过滤器映射列表
func (*ObjectField) GetArgValue ¶
func (o *ObjectField) GetArgValue(name string) map[string]map[string]string
GetArgValue 获取指令的参数值
func (*ObjectField) GetValidator ¶
func (o *ObjectField) GetValidator() string
GetValidator 获取字段的验证器类型
func (*ObjectField) GoTypeWithPointer ¶
func (o *ObjectField) GoTypeWithPointer() string
GoTypeWithPointer 返回带指针前缀的 Go 类型
func (*ObjectField) HasDirective ¶
func (o *ObjectField) HasDirective(name string) bool
func (*ObjectField) HasTargetObject ¶
func (o *ObjectField) HasTargetObject() bool
HasTargetObject 判断是否存在目标对象
func (*ObjectField) HasTargetObjectExtension ¶
func (o *ObjectField) HasTargetObjectExtension() bool
HasTargetObjectExtension 判断目标对象是否有扩展
func (*ObjectField) HasTargetTypeWithIDField ¶
func (o *ObjectField) HasTargetTypeWithIDField() bool
HasTargetTypeWithIDField 判断目标类型是否有 ID 字段
func (*ObjectField) IsCreataDocs ¶
func (o *ObjectField) IsCreataDocs() bool
IsCreataDocs 判断字段是否应出现在创建文档中
func (*ObjectField) IsCreatable ¶
func (o *ObjectField) IsCreatable() bool
IsCreatable 判断字段是否可用于创建操作
func (*ObjectField) IsEmbeddedColumn ¶
func (o *ObjectField) IsEmbeddedColumn() bool
IsEmbeddedColumn 判断是否为嵌入式列
func (*ObjectField) IsHasUpperId ¶
func (o *ObjectField) IsHasUpperId() bool
IsHasUpperId 判断是否为关系字段且包含 Id
func (*ObjectField) IsIdentifier ¶
func (o *ObjectField) IsIdentifier() bool
IsIdentifier 判断是否为 ID 标识符字段
func (*ObjectField) IsListType ¶
func (o *ObjectField) IsListType() bool
IsListType 判断是否为列表类型(解包 NonNull 后)
func (*ObjectField) IsOptional ¶
func (o *ObjectField) IsOptional() bool
IsOptional 判断是否为可选类型(非 NonNull)
func (*ObjectField) IsReadonlyType ¶
func (o *ObjectField) IsReadonlyType() bool
IsReadonlyType 判断是否为只读类型
func (*ObjectField) IsRelationship ¶
func (o *ObjectField) IsRelationship() bool
IsRelationship 判断是否为关系字段
func (*ObjectField) IsRelationshipIdentifier ¶
func (o *ObjectField) IsRelationshipIdentifier() bool
IsRelationshipIdentifier 判断是否为关系 ID 字段(如 userId)
func (*ObjectField) IsRelationshipRequired ¶
func (o *ObjectField) IsRelationshipRequired() bool
IsRelationshipRequired 判断关系是否为必填
func (*ObjectField) IsShardingID ¶
func (o *ObjectField) IsShardingID() bool
IsShardingID 判断是否为分片 ID 字段
func (*ObjectField) IsUpdatable ¶
func (o *ObjectField) IsUpdatable() bool
IsUpdatable 判断字段是否可用于更新操作
func (*ObjectField) IsWritableType ¶
func (o *ObjectField) IsWritableType() bool
IsWritableType 判断是否为可写类型
func (*ObjectField) MethodName ¶
func (o *ObjectField) MethodName() string
MethodName 返回适用于 Go 方法的字段名称(首字母大写)
func (*ObjectField) NeedsQueryResolver ¶
func (o *ObjectField) NeedsQueryResolver() bool
NeedsQueryResolver 判断是否需要查询解析器
func (*ObjectField) RelationshipName ¶
func (o *ObjectField) RelationshipName() string
RelationshipName 返回关系名称(移除 ID 后缀)
func (*ObjectField) RelationshipTypeName ¶
func (o *ObjectField) RelationshipTypeName() string
RelationshipTypeName 返回关系的类型名称
func (*ObjectField) TargetObjectExtension ¶
func (o *ObjectField) TargetObjectExtension() *ObjectExtension
TargetObjectExtension 返回目标对象的扩展
func (*ObjectField) TargetType ¶
func (o *ObjectField) TargetType() string
TargetType 返回字段的目标类型(解包 NonNull 和 List)
func (*ObjectField) ToSnakeName ¶
func (o *ObjectField) ToSnakeName() string
ToSnakeName 返回字段名称的蛇形命名形式
type ObjectFieldInput ¶
type ObjectFieldInput struct {
Def *ast.InputValueDefinition
Field *ObjectField
}
func (*ObjectFieldInput) IsListType ¶
func (o *ObjectFieldInput) IsListType() bool
func (*ObjectFieldInput) Name ¶
func (o *ObjectFieldInput) Name() string
func (*ObjectFieldInput) NonNullType ¶
func (o *ObjectFieldInput) NonNullType() string
func (*ObjectFieldInput) Required ¶
func (o *ObjectFieldInput) Required() bool
func (*ObjectFieldInput) TargetType ¶
func (o *ObjectFieldInput) TargetType() string
type ObjectRelationship ¶
type ObjectRelationship struct {
Def *ast.FieldDefinition
Obj *Object
}
func (*ObjectRelationship) BoolForRelationshipDirectiveAttribute ¶
func (o *ObjectRelationship) BoolForRelationshipDirectiveAttribute(name string) (val bool, ok bool)
func (*ObjectRelationship) ChangesName ¶
func (o *ObjectRelationship) ChangesName() string
func (*ObjectRelationship) ChangesType ¶
func (o *ObjectRelationship) ChangesType() string
func (*ObjectRelationship) GoType ¶
func (o *ObjectRelationship) GoType() string
func (*ObjectRelationship) InverseRelationship ¶
func (o *ObjectRelationship) InverseRelationship() *ObjectRelationship
func (*ObjectRelationship) InverseRelationshipName ¶
func (o *ObjectRelationship) InverseRelationshipName() string
func (*ObjectRelationship) IsDelete ¶
func (o *ObjectRelationship) IsDelete() bool
func (*ObjectRelationship) IsMainRelationshipForManyToMany ¶
func (o *ObjectRelationship) IsMainRelationshipForManyToMany() bool
func (*ObjectRelationship) IsManyToMany ¶
func (o *ObjectRelationship) IsManyToMany() bool
func (*ObjectRelationship) IsManyToOne ¶
func (o *ObjectRelationship) IsManyToOne() bool
func (*ObjectRelationship) IsMaster ¶
func (o *ObjectRelationship) IsMaster() bool
func (*ObjectRelationship) IsNonNull ¶
func (o *ObjectRelationship) IsNonNull() bool
func (*ObjectRelationship) IsOneToMany ¶
func (o *ObjectRelationship) IsOneToMany() bool
func (*ObjectRelationship) IsOneToOne ¶
func (o *ObjectRelationship) IsOneToOne() bool
func (*ObjectRelationship) IsSelfReferencing ¶
func (o *ObjectRelationship) IsSelfReferencing() bool
func (*ObjectRelationship) IsToMany ¶
func (o *ObjectRelationship) IsToMany() bool
func (*ObjectRelationship) IsToOne ¶
func (o *ObjectRelationship) IsToOne() bool
func (*ObjectRelationship) JoinString ¶
func (o *ObjectRelationship) JoinString() string
func (*ObjectRelationship) LowerName ¶
func (o *ObjectRelationship) LowerName() string
func (*ObjectRelationship) MainRelationshipForManyToMany ¶
func (o *ObjectRelationship) MainRelationshipForManyToMany() *ObjectRelationship
func (*ObjectRelationship) ManyToManyJoinTable ¶
func (o *ObjectRelationship) ManyToManyJoinTable() string
func (*ObjectRelationship) MethodName ¶
func (o *ObjectRelationship) MethodName() string
func (*ObjectRelationship) ModelTags ¶
func (o *ObjectRelationship) ModelTags() string
func (*ObjectRelationship) Name ¶
func (o *ObjectRelationship) Name() string
func (*ObjectRelationship) Preload ¶
func (o *ObjectRelationship) Preload() bool
func (*ObjectRelationship) ReturnType ¶
func (o *ObjectRelationship) ReturnType() string
func (*ObjectRelationship) StringForRelationshipDirectiveAttribute ¶
func (o *ObjectRelationship) StringForRelationshipDirectiveAttribute(name string) (val string, ok bool)
func (*ObjectRelationship) Target ¶
func (o *ObjectRelationship) Target() *Object
func (*ObjectRelationship) TargetType ¶
func (o *ObjectRelationship) TargetType() string
func (*ObjectRelationship) TargetTypeToSnakeName ¶
func (o *ObjectRelationship) TargetTypeToSnakeName() string
func (*ObjectRelationship) ToSnakeName ¶
func (o *ObjectRelationship) ToSnakeName() string
func (*ObjectRelationship) ToSnakeRelationshipName ¶
func (o *ObjectRelationship) ToSnakeRelationshipName() string
func (*ObjectRelationship) UpperRelationshipName ¶
func (o *ObjectRelationship) UpperRelationshipName() string
func (*ObjectRelationship) ValueForRelationshipDirectiveAttribute ¶
func (o *ObjectRelationship) ValueForRelationshipDirectiveAttribute(name string) (val interface{}, ok bool)
Source Files
¶
- config.go
- definition.federation.go
- definition.filter.go
- definition.inputs.go
- definition.mutation.go
- definition.query.go
- definition.result-type.go
- definition.sorting.go
- enrichment.go
- enums.go
- generics.go
- graphql-helpers.go
- model.go
- model.object-extension.go
- model.object-field-directives.go
- model.object-field-input.go
- model.object-field.go
- model.object-relationship.go
- model.object.go
- parser.go
- printer.go
- utils.go