Documentation ¶
Index ¶
- Constants
- type DefObjectType
- type Definition
- type Definitions
- type FieldDefType
- type FieldDefinition
- type FieldDefinitions
- type FileNamer
- type PluginsCfg
- type Positioner
- type Positioners
- type QuerySplitConfig
- type QuerySplitConfigs
- type QueryViewData
- type Shifter
- type Shifters
- type Source
- type SourceType
- type Sources
- type SourcesDefs
- type SourcesFields
- type SourcesMap
- type SplitterConfig
- type TypeSplitConfig
- type TypeSplitConfigs
- type TypeViewData
- type TypesSplitterPlugin
Constants ¶
const ( PluginName = "types_splitter" ResolversSuffix = ".resolvers" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefObjectType ¶
type DefObjectType uint32
const ( DefQueryObject DefObjectType = iota DefMutationObject DefSubscriptionObject DefTypeObject DefInputObject DefScalar )
type Definition ¶
type Definition struct { *ast.Definition Content string Fields FieldDefinitions // ActualPosition is the actual position of the definition in the source // including documentation and its entire scope ActualPosition *ast.Position // contains filtered or unexported fields }
Definition is a wrapper around ast.Definition that implements Positioner which is used for Query, Mutation, Subscription, and Type definitions
func WrapDefinition ¶
func WrapDefinition(def *ast.Definition, typ DefObjectType) *Definition
func (*Definition) ActualPos ¶
func (d *Definition) ActualPos() *ast.Position
ActualPos returns the actual position of the definition in the source
func (*Definition) AddFields ¶
func (d *Definition) AddFields(fields FieldDefinitions)
func (*Definition) Pos ¶
func (d *Definition) Pos() *ast.Position
Pos returns the position of the definition including the source ref
func (*Definition) ShiftOffset ¶
func (d *Definition) ShiftOffset(offset, lines int)
ShiftOffset shifts the position of the definition by the given offset and lines
type Definitions ¶
type Definitions []*Definition
Definitions is a list of Definition
func WrapDefinitions ¶
func WrapDefinitions(defList ast.DefinitionList, typ DefObjectType) Definitions
WrapDefinitions wraps a list of ast.Definition into a list of Definition
func (Definitions) PosAfter ¶
func (ds Definitions) PosAfter(offset int) Positioners
PosAfter returns a list of Positioners that are defined after the given offset
func (Definitions) ShiftOffset ¶
func (ds Definitions) ShiftOffset(offset int, lines int)
ShiftOffset shifts the position of the definitions by the given offset and lines
type FieldDefType ¶
type FieldDefType uint32
const ( DefQueryField FieldDefType = iota DefMutationField DefSubscriptionField DefObjectField )
type FieldDefinition ¶
type FieldDefinition struct { *ast.FieldDefinition Content string ActualPosition *ast.Position // contains filtered or unexported fields }
FieldDefinition is a wrapper around ast.FieldDefinition that implements Positioner which is used for Field definitions in Query, Mutation, Subscription, and Type definitions
func WrapFieldDefinition ¶
func WrapFieldDefinition(field *ast.FieldDefinition, typ FieldDefType) *FieldDefinition
func (*FieldDefinition) ActualPos ¶
func (fd *FieldDefinition) ActualPos() *ast.Position
func (*FieldDefinition) Pos ¶
func (fd *FieldDefinition) Pos() *ast.Position
Pos returns the position of the field definition including the source ref
func (*FieldDefinition) ShiftOffset ¶
func (fd *FieldDefinition) ShiftOffset(offset, lines int)
ShiftOffset shifts the position of the field definition by the given offset and lines
type FieldDefinitions ¶
type FieldDefinitions []*FieldDefinition
FieldDefinitions is a list of FieldDefinition
func (FieldDefinitions) FindAstField ¶
func (ds FieldDefinitions) FindAstField(field *ast.FieldDefinition) *FieldDefinition
FindAstField returns the FieldDefinition that wraps the given ast.FieldDefinition
func (FieldDefinitions) PosAfter ¶
func (ds FieldDefinitions) PosAfter(offset int) Positioners
PosAfter returns a list of Positioners that are defined after the given offset
func (FieldDefinitions) ShiftOffset ¶
func (ds FieldDefinitions) ShiftOffset(offset int, lines int)
ShiftOffset shifts the position of the FieldDefinitions by the given offset and lines
type PluginsCfg ¶
type PluginsCfg struct {
Splitter *SplitterConfig `yaml:"types_splitter"`
}
PluginsCfg is a configuration for the plugin.
type Positioner ¶
Positioner is an interface for types that can return their position
type Positioners ¶
type Positioners interface {
PosAfter(offset int) Positioners
}
Positioners is an interface for types that can return a list of Positioners
type QuerySplitConfig ¶
type QuerySplitConfig struct { // ResolverPrefix is the prefix that will be added to the resolver file name eg. racing => racing.queries.go. ResolverPrefix string `yaml:"prefix"` // Matches is a list of string regexes that will be used to match against the query name. They must be ordered by priority. Matches []string `yaml:"matches"` // contains filtered or unexported fields }
QuerySplitConfig is a configuration for splitting queries and mutations into multiple files.
type QuerySplitConfigs ¶
type QuerySplitConfigs []QuerySplitConfig
func (QuerySplitConfigs) FindResolverPrefix ¶
func (qs QuerySplitConfigs) FindResolverPrefix(queryName string) (string, bool)
FindResolverPrefix returns the resolver prefix for the given query name.
type QueryViewData ¶
type QueryViewData struct { Type string Fields FieldDefinitions }
type Shifter ¶
type Shifter interface { Positioner ShiftOffset(offset, lines int) }
Shifter is an interface for types that can shift their position
type Shifters ¶
type Shifters interface { Positioners ShiftOffset(offset, lines int) }
Shifters is an interface for types that can shift a list of Positioners
type Source ¶
type Source struct { *ast.Source Fields FieldDefinitions Types Definitions // contains filtered or unexported fields }
Source is a wrapper around ast.Source that implements Positioner
func NewSource ¶
func NewSource(name string, sourceType SourceType) (*Source, error)
NewSource creates a new Source
func (*Source) GenerateInput ¶
type SourceType ¶
type SourceType uint32
const ( OriginalSource SourceType = iota SourceQueryExtended SourceMutationExtended SourceSubscriptionExtended SourceObject SourceInput )
type Sources ¶
type Sources []*Source
Sources is a list of Source
func WrapSources ¶
WrapSources wraps a list of ast.Source into a list of Source
type SourcesDefs ¶
type SourcesDefs map[string]Definitions
SourcesDefs is a map of source names to Definitions
type SourcesFields ¶
type SourcesFields map[string]FieldDefinitions
SourcesFields is a map of source names to FieldDefinitions
type SplitterConfig ¶
type SplitterConfig struct { QueryConfig QuerySplitConfigs `yaml:"queries"` TypeConfig TypeSplitConfigs `yaml:"types"` }
SplitterConfig is a configuration for splitting queries, mutations, subscriptions and types into multiple files.
type TypeSplitConfig ¶
type TypeSplitConfig struct { // Name is the name of the type that will be used to match against the type name. eg. RacingRace Name string `yaml:"name"` // ResolverPrefix is the prefix that will be added to the resolver file name eg. racing_race => racing_race.resolvers.go. ResolverPrefix string `yaml:"prefix"` }
TypeSplitConfig is a configuration for splitting types into multiple files.
type TypeSplitConfigs ¶
type TypeSplitConfigs []TypeSplitConfig
func (TypeSplitConfigs) FindResolverPrefix ¶
func (ts TypeSplitConfigs) FindResolverPrefix(typeName string) (string, bool)
FindResolverPrefix returns the resolver prefix for the given type name.
type TypeViewData ¶
type TypeViewData struct { Type string Types Definitions }
type TypesSplitterPlugin ¶
type TypesSplitterPlugin struct {
// contains filtered or unexported fields
}
TypesSplitterPlugin is a plugin that splits the schema into multiple files.
func New ¶
func New(cfgFilePath string) (*TypesSplitterPlugin, error)
New creates a new TypesSplitterPlugin.
func (*TypesSplitterPlugin) MutateConfig ¶
func (s *TypesSplitterPlugin) MutateConfig(genCfg *config.Config) error
MutateConfig implements plugin.ConfigMutator
func (*TypesSplitterPlugin) Name ¶
func (s *TypesSplitterPlugin) Name() string
Name implements plugin.Plugin