Documentation ¶
Index ¶
- func AnalyzePlanKind(operation, definition *ast.Document, operationName string) (subscription, streaming bool, error error)
- type ArgumentConfiguration
- type ArgumentsConfigurations
- type Configuration
- type DataSourceConfiguration
- type DataSourcePlanner
- type DataSourcePlanningBehavior
- type FetchConfiguration
- type FieldConfiguration
- type FieldConfigurations
- type FieldMapping
- type Kind
- type LocalTypeFieldExtractor
- type Plan
- type Planner
- type PlannerFactory
- type RequiredFieldExtractor
- type SourceType
- type StreamingResponsePlan
- type SubscriptionConfiguration
- type SubscriptionResponsePlan
- type SynchronousResponsePlan
- type TypeField
- type Visitor
- func (v *Visitor) AllowVisitor(kind astvisitor.VisitorKind, ref int, visitor interface{}) bool
- func (v *Visitor) EnterDirective(ref int)
- func (v *Visitor) EnterDocument(operation, definition *ast.Document)
- func (v *Visitor) EnterField(ref int)
- func (v *Visitor) EnterOperationDefinition(ref int)
- func (v *Visitor) EnterSelectionSet(ref int)
- func (v *Visitor) LeaveDocument(operation, definition *ast.Document)
- func (v *Visitor) LeaveField(ref int)
- func (v *Visitor) LeaveSelectionSet(ref int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArgumentConfiguration ¶
type ArgumentConfiguration struct { Name string SourceType SourceType SourcePath []string }
type ArgumentsConfigurations ¶
type ArgumentsConfigurations []ArgumentConfiguration
func (ArgumentsConfigurations) ForName ¶
func (a ArgumentsConfigurations) ForName(argName string) *ArgumentConfiguration
type Configuration ¶
type Configuration struct { DefaultFlushInterval int64 DataSources []DataSourceConfiguration Fields FieldConfigurations Schema string }
type DataSourceConfiguration ¶
type DataSourceConfiguration struct { RootNodes []TypeField ChildNodes []TypeField Factory PlannerFactory Custom json.RawMessage }
func (*DataSourceConfiguration) HasRootNode ¶
func (d *DataSourceConfiguration) HasRootNode(typeName, fieldName string) bool
type DataSourcePlanner ¶
type DataSourcePlanner interface { Register(visitor *Visitor, customConfiguration json.RawMessage, isNested bool) error ConfigureFetch() FetchConfiguration ConfigureSubscription() SubscriptionConfiguration DataSourcePlanningBehavior() DataSourcePlanningBehavior // DownstreamResponseFieldAlias allows the DataSourcePlanner to overwrite the response path with an alias // It's required to set OverrideFieldPathFromAlias to true // This function is useful in the following scenario // 1. The downstream Query doesn't contain an alias // 2. The path configuration rewrites the field to an existing field // 3. The DataSourcePlanner is using an alias to the upstream // Example: // // type Query { // country: Country // countryAlias: Country // } // // Both, country and countryAlias have a path in the FieldConfiguration of "country" // In theory, they would be treated as the same field // However, by using DownstreamResponseFieldAlias, it's possible for the DataSourcePlanner to use an alias for countryAlias. // In this case, the response would contain both, country and countryAlias fields in the response. // At the same time, the downstream Query would only expect the response on the path "country", // as both country and countryAlias have a mapping to the path "country". // The DataSourcePlanner could keep track that it rewrites the upstream query and use DownstreamResponseFieldAlias // to indicate to the Planner to expect the response for countryAlias on the path "countryAlias" instead of "country". DownstreamResponseFieldAlias(downstreamFieldRef int) (alias string, exists bool) }
type DataSourcePlanningBehavior ¶
type DataSourcePlanningBehavior struct { // MergeAliasedRootNodes will reuse a data source for multiple root fields with aliases if true. // Example: // { // rootField // alias: rootField // } // On dynamic data sources (e.g. GraphQL, SQL, ...) this should return true and for // static data sources (e.g. REST, static, GRPC...) it should be false. MergeAliasedRootNodes bool // OverrideFieldPathFromAlias will let the planner know if the response path should also be aliased (= true) // or not (= false) // Example: // { // rootField // alias: original // } // When true expected response will be { "rootField": ..., "alias": ... } // When false expected response will be { "rootField": ..., "original": ... } OverrideFieldPathFromAlias bool }
type FetchConfiguration ¶
type FieldConfiguration ¶
type FieldConfigurations ¶
type FieldConfigurations []FieldConfiguration
func (FieldConfigurations) ForTypeField ¶
func (f FieldConfigurations) ForTypeField(typeName, fieldName string) *FieldConfiguration
type FieldMapping ¶
type LocalTypeFieldExtractor ¶ added in v1.14.0
type LocalTypeFieldExtractor struct {
// contains filtered or unexported fields
}
LocalTypeFieldExtractor takes an ast.Document as input and generates the TypeField configuration for both root fields & child fields If a type is a federation entity (annotated with @key directive) and a field is is extended, this field will be skipped so that only "local" fields will be generated
func NewLocalTypeFieldExtractor ¶ added in v1.14.0
func NewLocalTypeFieldExtractor(document *ast.Document) *LocalTypeFieldExtractor
func (*LocalTypeFieldExtractor) GetAllNodes ¶ added in v1.14.0
func (e *LocalTypeFieldExtractor) GetAllNodes() (rootNodes, childNodes []TypeField)
GetAllNodes returns all Root- & ChildNodes
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
func NewPlanner ¶
func NewPlanner(config Configuration) *Planner
func (*Planner) SetConfig ¶
func (p *Planner) SetConfig(config Configuration)
type PlannerFactory ¶
type PlannerFactory interface {
Planner() DataSourcePlanner
}
type RequiredFieldExtractor ¶ added in v1.14.0
type RequiredFieldExtractor struct {
// contains filtered or unexported fields
}
RequiredFieldExtractor extracts all required fields from an ast.Document containing a parsed federation subgraph SDL by visiting the directives specified in the federation specification and extracting the required meta data
func NewRequiredFieldExtractor ¶ added in v1.14.0
func NewRequiredFieldExtractor(document *ast.Document) *RequiredFieldExtractor
func (*RequiredFieldExtractor) GetAllRequiredFields ¶ added in v1.14.0
func (f *RequiredFieldExtractor) GetAllRequiredFields() FieldConfigurations
type SourceType ¶
type SourceType string
const ( ObjectFieldSource SourceType = "object_field" FieldArgumentSource SourceType = "field_argument" )
type StreamingResponsePlan ¶
type StreamingResponsePlan struct { Response resolve.GraphQLStreamingResponse FlushInterval int64 }
func (*StreamingResponsePlan) PlanKind ¶
func (_ *StreamingResponsePlan) PlanKind() Kind
func (*StreamingResponsePlan) SetFlushInterval ¶
func (s *StreamingResponsePlan) SetFlushInterval(interval int64)
type SubscriptionResponsePlan ¶
type SubscriptionResponsePlan struct { Response resolve.GraphQLSubscription FlushInterval int64 }
func (*SubscriptionResponsePlan) PlanKind ¶
func (_ *SubscriptionResponsePlan) PlanKind() Kind
func (*SubscriptionResponsePlan) SetFlushInterval ¶
func (s *SubscriptionResponsePlan) SetFlushInterval(interval int64)
type SynchronousResponsePlan ¶
type SynchronousResponsePlan struct { Response *resolve.GraphQLResponse FlushInterval int64 }
func (*SynchronousResponsePlan) PlanKind ¶
func (_ *SynchronousResponsePlan) PlanKind() Kind
func (*SynchronousResponsePlan) SetFlushInterval ¶
func (s *SynchronousResponsePlan) SetFlushInterval(interval int64)
type Visitor ¶
type Visitor struct {
Operation, Definition *ast.Document
Walker *astvisitor.Walker
Importer astimport.Importer
Config Configuration
OperationName string
// contains filtered or unexported fields
}
func (*Visitor) AllowVisitor ¶
func (v *Visitor) AllowVisitor(kind astvisitor.VisitorKind, ref int, visitor interface{}) bool
func (*Visitor) EnterDirective ¶
func (*Visitor) EnterDocument ¶
func (*Visitor) EnterField ¶
func (*Visitor) EnterOperationDefinition ¶
func (*Visitor) EnterSelectionSet ¶
func (*Visitor) LeaveDocument ¶
func (*Visitor) LeaveField ¶
func (*Visitor) LeaveSelectionSet ¶
Click to show internal directories.
Click to hide internal directories.