federation

package
v0.0.0-...-2952f12 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoreDirective = &ast.DirectiveDefinition{
	Name: "core",
	Arguments: ast.ArgumentDefinitionList{
		&ast.ArgumentDefinition{
			Name: "feature",
			Type: &ast.Type{
				NamedType: "String",
				NonNull:   true,
			},
		},
		&ast.ArgumentDefinition{
			Name: "as",
			Type: &ast.Type{
				NamedType: "String",
			},
		},
		&ast.ArgumentDefinition{
			Name: "for",
			Type: &ast.Type{
				NamedType: CorePurpose.Name,
			},
		},
	},
	Locations: []ast.DirectiveLocation{
		ast.LocationSchema,
	},
	IsRepeatable: true,
	Position:     blankPos,
}
View Source
var CorePurpose = &ast.Definition{
	Kind: ast.Enum,
	Name: "core__Purpose",
	EnumValues: ast.EnumValueList{
		&ast.EnumValueDefinition{
			Name:        "EXECUTION",
			Description: "`EXECUTION` features provide metadata necessary to for operation execution.",
		},
		&ast.EnumValueDefinition{
			Name:        "SECURITY",
			Description: "`SECURITY` features provide metadata necessary to securely resolve fields.",
		},
	},
	Position: blankPos,
}
View Source
var FieldSetScalar = &ast.Definition{
	Kind:     ast.Scalar,
	Name:     "join__FieldSet",
	Position: blankPos,
}
View Source
var JoinGraphDirective = &ast.DirectiveDefinition{
	Name: "join__graph",
	Arguments: ast.ArgumentDefinitionList{
		&ast.ArgumentDefinition{
			Name: "name",
			Type: &ast.Type{
				NamedType: "String",
				NonNull:   true,
			},
		},
		&ast.ArgumentDefinition{
			Name: "url",
			Type: &ast.Type{
				NamedType: "String",
				NonNull:   true,
			},
		},
	},
	Locations: []ast.DirectiveLocation{
		ast.LocationEnumValue,
	},
	Position: blankPos,
}

Functions

This section is empty.

Types

type DirectiveDefinitionsMap

type DirectiveDefinitionsMap map[string]map[string]*ast.DirectiveDefinition

Map of all directive definitions to eventually be passed to extendSchema original: [name: string]: { [serviceName: string]: DirectiveDefinitionNode };

type DirectiveMetadata

type DirectiveMetadata struct {
	DirectiveUsagesPerSubgraph DirectiveUsagesPerSubgraph
}

func (*DirectiveMetadata) HasUsage

func (dm *DirectiveMetadata) HasUsage(directiveName string) bool

visit the entire map for any usages of a directive

type DirectiveUsages

type DirectiveUsages map[string]ast.DirectiveList

directive name => usages

type DirectiveUsagesPerField

type DirectiveUsagesPerField map[string]DirectiveUsages

field name => directive name => usages

type DirectiveUsagesPerSubgraph

type DirectiveUsagesPerSubgraph map[string]DirectiveUsagesPerType

subgraph name => DirectiveUsagesPerType

type DirectiveUsagesPerType

type DirectiveUsagesPerType map[string]*DirectiveUsagesPerTypeEntity
type name => {
  directives: DirectiveUsages,
  fields: DirectiveUsagesPerField
}

type DirectiveUsagesPerTypeEntity

type DirectiveUsagesPerTypeEntity struct {
	Directives DirectiveUsages
	Fields     DirectiveUsagesPerField
}

type ExternalFieldDefinition

type ExternalFieldDefinition struct {
	Field          *ast.FieldDefinition
	ParentTypeName string
	ServiceName    string
}

type FederationDirective

type FederationDirective struct {
	DirectiveDefinitions map[string]*ast.DirectiveDefinition
}

type FederationDirectiveMap

type FederationDirectiveMap map[*ast.DirectiveDefinition]*FederationDirective

func (FederationDirectiveMap) Get

type FederationField

type FederationField struct {
	ServiceName        ServiceName
	ParentType         *ast.Definition
	Provides           ast.SelectionSet
	Requires           ast.SelectionSet
	BelongsToValueType bool
	DirectiveUsages    DirectiveUsages
}

type FederationFieldMap

type FederationFieldMap map[*ast.FieldDefinition]*FederationField

func (FederationFieldMap) Get

type FederationMetadata

type FederationMetadata struct {
	FederationTypeMap      FederationTypeMap
	FederationFieldMap     FederationFieldMap
	FederationDirectiveMap FederationDirectiveMap
}

func ComposeAndValidate

func ComposeAndValidate(ctx context.Context, serviceList []*ServiceDefinition) (schema *ast.Schema, supergraphSDL string, matadata *FederationMetadata, err error)

type FederationType

type FederationType struct {
	ServiceName     ServiceName
	Keys            ServiceNameToKeyDirectivesMap
	Externals       map[string][]*ExternalFieldDefinition
	IsValueType     bool
	DirectiveUsages DirectiveUsages
}

type FederationTypeMap

type FederationTypeMap map[*ast.Definition]*FederationType

func (FederationTypeMap) Get

type KeyDirectivesMap

type KeyDirectivesMap map[string]ServiceNameToKeyDirectivesMap

Map of types to their key directives (maintains association to their services)

Example resulting KeyDirectivesMap shape:

const keyDirectives = {
  Product: {
    serviceA: ["sku", "upc"]
    serviceB: ["color {id value}"] // Selection node simplified for readability
  }
}

original: [typeName: string]: ServiceNameToKeyDirectivesMap;

type ServiceDefinition

type ServiceDefinition struct {
	TypeDefs *ast.SchemaDocument
	Name     string
	URL      string // optional
}

type ServiceName

type ServiceName = string

type ServiceNameToKeyDirectivesMap

type ServiceNameToKeyDirectivesMap map[string][]ast.SelectionSet

original: [serviceName: string]: ReadonlyArray<SelectionNode>[] | undefined;

type TypeDefinitionEntity

type TypeDefinitionEntity struct {
	ServiceName string
	Definition  *ast.Definition
}

type TypeDefinitionsMap

type TypeDefinitionsMap map[string][]*TypeDefinitionEntity

Map of all type definitions to eventually be passed to extendSchema

type TypeToServiceEntity

type TypeToServiceEntity struct {
	OwningService                     string // optional
	ExtensionFieldsToOwningServiceMap map[string]string
}

type TypeToServiceMap

type TypeToServiceMap map[string]*TypeToServiceEntity

A map of base types to their owning service. Used by query planner to direct traffic. This contains the base type's "owner". Any fields that extend this type in another service are listed under "extensionFieldsToOwningServiceMap". extensionFieldsToOwningServiceMap are in the format { myField: my-service-name }

Example resulting typeToServiceMap shape:

const typeToServiceMap = {
  Product: {
    serviceName: "ProductService",
    extensionFieldsToOwningServiceMap: {
      reviews: "ReviewService", // Product.reviews comes from the ReviewService
      dimensions: "ShippingService",
      weight: "ShippingService"
    }
  }
}

original: [typeName: string]: { owningService?: string; extensionFieldsToOwningServiceMap: { [fieldName: string]: string }; };

type ValueTypes

type ValueTypes []string

A set of type names that have been determined to be a value type, a type shared across at least 2 services. original: type ValueTypes = Set<string>;

func (ValueTypes) Has

func (vts ValueTypes) Has(name string) bool

Jump to

Keyboard shortcuts

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