federation

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectTypes

func CollectTypes(typ internal.Type, types map[internal.Type]string) error

CollectTypes finds all types reachable from typ and stores them in types as a map from type to name.

TODO: Stick this in an internal package.

func ConvertResponse

func ConvertResponse(response *FederationResponse) *graphql.Response

func RegisterFederationServiceServer

func RegisterFederationServiceServer(s *grpc.Server, srv FederationServiceServer)

Types

type Directive

type Directive struct {
	Name                 string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	ArgVals              *any.Any  `protobuf:"bytes,2,opt,name=argVals,proto3" json:"argVals,omitempty"`
	Loc                  *Location `protobuf:"bytes,3,opt,name=loc,proto3" json:"loc,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*Directive) Descriptor

func (*Directive) Descriptor() ([]byte, []int)

func (*Directive) GetArgVals

func (m *Directive) GetArgVals() *any.Any

func (*Directive) GetLoc

func (m *Directive) GetLoc() *Location

func (*Directive) GetName

func (m *Directive) GetName() string

func (*Directive) ProtoMessage

func (*Directive) ProtoMessage()

func (*Directive) Reset

func (m *Directive) Reset()

func (*Directive) String

func (m *Directive) String() string

func (*Directive) XXX_DiscardUnknown

func (m *Directive) XXX_DiscardUnknown()

func (*Directive) XXX_Marshal

func (m *Directive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Directive) XXX_Merge

func (m *Directive) XXX_Merge(src proto.Message)

func (*Directive) XXX_Size

func (m *Directive) XXX_Size() int

func (*Directive) XXX_Unmarshal

func (m *Directive) XXX_Unmarshal(b []byte) error

type FederationRequest

type FederationRequest struct {
	Kind                 string        `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
	SelectionSet         *SelectionSet `protobuf:"bytes,2,opt,name=selectionSet,proto3" json:"selectionSet,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (*FederationRequest) Descriptor

func (*FederationRequest) Descriptor() ([]byte, []int)

func (*FederationRequest) GetKind

func (m *FederationRequest) GetKind() string

func (*FederationRequest) GetSelectionSet

func (m *FederationRequest) GetSelectionSet() *SelectionSet

func (*FederationRequest) ProtoMessage

func (*FederationRequest) ProtoMessage()

func (*FederationRequest) Reset

func (m *FederationRequest) Reset()

func (*FederationRequest) String

func (m *FederationRequest) String() string

func (*FederationRequest) XXX_DiscardUnknown

func (m *FederationRequest) XXX_DiscardUnknown()

func (*FederationRequest) XXX_Marshal

func (m *FederationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FederationRequest) XXX_Merge

func (m *FederationRequest) XXX_Merge(src proto.Message)

func (*FederationRequest) XXX_Size

func (m *FederationRequest) XXX_Size() int

func (*FederationRequest) XXX_Unmarshal

func (m *FederationRequest) XXX_Unmarshal(b []byte) error

type FederationResponse

type FederationResponse struct {
	Data                 *any.Any        `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	Errors               []*GraphQLError `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"`
	XXX_NoUnkeyedLiteral struct{}        `json:"-"`
	XXX_unrecognized     []byte          `json:"-"`
	XXX_sizecache        int32           `json:"-"`
}

func ConvertToResponse

func ConvertToResponse(data interface{}, errs errors.MultiError) *FederationResponse

func (*FederationResponse) Descriptor

func (*FederationResponse) Descriptor() ([]byte, []int)

func (*FederationResponse) GetData

func (m *FederationResponse) GetData() *any.Any

func (*FederationResponse) GetErrors

func (m *FederationResponse) GetErrors() []*GraphQLError

func (*FederationResponse) ProtoMessage

func (*FederationResponse) ProtoMessage()

func (*FederationResponse) Reset

func (m *FederationResponse) Reset()

func (*FederationResponse) String

func (m *FederationResponse) String() string

func (*FederationResponse) XXX_DiscardUnknown

func (m *FederationResponse) XXX_DiscardUnknown()

func (*FederationResponse) XXX_Marshal

func (m *FederationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FederationResponse) XXX_Merge

func (m *FederationResponse) XXX_Merge(src proto.Message)

func (*FederationResponse) XXX_Size

func (m *FederationResponse) XXX_Size() int

func (*FederationResponse) XXX_Unmarshal

func (m *FederationResponse) XXX_Unmarshal(b []byte) error

type FederationServiceClient

type FederationServiceClient interface {
	Execute(ctx context.Context, in *FederationRequest, opts ...grpc.CallOption) (*FederationResponse, error)
	Introspection(ctx context.Context, in *Null, opts ...grpc.CallOption) (*FederationResponse, error)
	Subscription(ctx context.Context, in *FederationRequest, opts ...grpc.CallOption) (FederationService_SubscriptionClient, error)
}

FederationServiceClient is the client API for FederationService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type FederationServiceServer

type FederationServiceServer interface {
	Execute(context.Context, *FederationRequest) (*FederationResponse, error)
	Introspection(context.Context, *Null) (*FederationResponse, error)
	Subscription(*FederationRequest, FederationService_SubscriptionServer) error
}

FederationServiceServer is the server API for FederationService service.

type FederationService_SubscriptionClient

type FederationService_SubscriptionClient interface {
	Recv() (*FederationResponse, error)
	grpc.ClientStream
}

type FederationService_SubscriptionServer

type FederationService_SubscriptionServer interface {
	Send(*FederationResponse) error
	grpc.ServerStream
}

type FieldInfo

type FieldInfo struct {
	// Services is the set of all services that can resolve this
	// field. If a service has multiple versions, all versions
	// must be able to resolve the field.
	Services map[string]bool
}

FieldInfo holds federation-specific information for system.Fields used to plan and execute queries.

type FragmentDefinition

type FragmentDefinition struct {
	Name                 string        `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	On                   string        `protobuf:"bytes,2,opt,name=on,proto3" json:"on,omitempty"`
	SelectionSet         *SelectionSet `protobuf:"bytes,3,opt,name=selectionSet,proto3" json:"selectionSet,omitempty"`
	Loc                  *Location     `protobuf:"bytes,4,opt,name=loc,proto3" json:"loc,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (*FragmentDefinition) Descriptor

func (*FragmentDefinition) Descriptor() ([]byte, []int)

func (*FragmentDefinition) GetLoc

func (m *FragmentDefinition) GetLoc() *Location

func (*FragmentDefinition) GetName

func (m *FragmentDefinition) GetName() string

func (*FragmentDefinition) GetOn

func (m *FragmentDefinition) GetOn() string

func (*FragmentDefinition) GetSelectionSet

func (m *FragmentDefinition) GetSelectionSet() *SelectionSet

func (*FragmentDefinition) ProtoMessage

func (*FragmentDefinition) ProtoMessage()

func (*FragmentDefinition) Reset

func (m *FragmentDefinition) Reset()

func (*FragmentDefinition) String

func (m *FragmentDefinition) String() string

func (*FragmentDefinition) XXX_DiscardUnknown

func (m *FragmentDefinition) XXX_DiscardUnknown()

func (*FragmentDefinition) XXX_Marshal

func (m *FragmentDefinition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FragmentDefinition) XXX_Merge

func (m *FragmentDefinition) XXX_Merge(src proto.Message)

func (*FragmentDefinition) XXX_Size

func (m *FragmentDefinition) XXX_Size() int

func (*FragmentDefinition) XXX_Unmarshal

func (m *FragmentDefinition) XXX_Unmarshal(b []byte) error

type FragmentSpread

type FragmentSpread struct {
	Loc                  *Location           `protobuf:"bytes,1,opt,name=loc,proto3" json:"loc,omitempty"`
	Fragment             *FragmentDefinition `protobuf:"bytes,2,opt,name=fragment,proto3" json:"fragment,omitempty"`
	Directives           []*Directive        `protobuf:"bytes,3,rep,name=directives,proto3" json:"directives,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

func (*FragmentSpread) Descriptor

func (*FragmentSpread) Descriptor() ([]byte, []int)

func (*FragmentSpread) GetDirectives

func (m *FragmentSpread) GetDirectives() []*Directive

func (*FragmentSpread) GetFragment

func (m *FragmentSpread) GetFragment() *FragmentDefinition

func (*FragmentSpread) GetLoc

func (m *FragmentSpread) GetLoc() *Location

func (*FragmentSpread) ProtoMessage

func (*FragmentSpread) ProtoMessage()

func (*FragmentSpread) Reset

func (m *FragmentSpread) Reset()

func (*FragmentSpread) String

func (m *FragmentSpread) String() string

func (*FragmentSpread) XXX_DiscardUnknown

func (m *FragmentSpread) XXX_DiscardUnknown()

func (*FragmentSpread) XXX_Marshal

func (m *FragmentSpread) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FragmentSpread) XXX_Merge

func (m *FragmentSpread) XXX_Merge(src proto.Message)

func (*FragmentSpread) XXX_Size

func (m *FragmentSpread) XXX_Size() int

func (*FragmentSpread) XXX_Unmarshal

func (m *FragmentSpread) XXX_Unmarshal(b []byte) error

type GraphQLError

type GraphQLError struct {
	Message              string      `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Locations            []*Location `protobuf:"bytes,2,rep,name=locations,proto3" json:"locations,omitempty"`
	Path                 []string    `protobuf:"bytes,3,rep,name=path,proto3" json:"path,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

func (*GraphQLError) Descriptor

func (*GraphQLError) Descriptor() ([]byte, []int)

func (*GraphQLError) GetLocations

func (m *GraphQLError) GetLocations() []*Location

func (*GraphQLError) GetMessage

func (m *GraphQLError) GetMessage() string

func (*GraphQLError) GetPath

func (m *GraphQLError) GetPath() []string

func (*GraphQLError) ProtoMessage

func (*GraphQLError) ProtoMessage()

func (*GraphQLError) Reset

func (m *GraphQLError) Reset()

func (*GraphQLError) String

func (m *GraphQLError) String() string

func (*GraphQLError) XXX_DiscardUnknown

func (m *GraphQLError) XXX_DiscardUnknown()

func (*GraphQLError) XXX_Marshal

func (m *GraphQLError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GraphQLError) XXX_Merge

func (m *GraphQLError) XXX_Merge(src proto.Message)

func (*GraphQLError) XXX_Size

func (m *GraphQLError) XXX_Size() int

func (*GraphQLError) XXX_Unmarshal

func (m *GraphQLError) XXX_Unmarshal(b []byte) error

type Location

type Location struct {
	Line                 int32    `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"`
	Column               int32    `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Location) Descriptor

func (*Location) Descriptor() ([]byte, []int)

func (*Location) GetColumn

func (m *Location) GetColumn() int32

func (*Location) GetLine

func (m *Location) GetLine() int32

func (*Location) ProtoMessage

func (*Location) ProtoMessage()

func (*Location) Reset

func (m *Location) Reset()

func (*Location) String

func (m *Location) String() string

func (*Location) XXX_DiscardUnknown

func (m *Location) XXX_DiscardUnknown()

func (*Location) XXX_Marshal

func (m *Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Location) XXX_Merge

func (m *Location) XXX_Merge(src proto.Message)

func (*Location) XXX_Size

func (m *Location) XXX_Size() int

func (*Location) XXX_Unmarshal

func (m *Location) XXX_Unmarshal(b []byte) error

type MergeMode

type MergeMode string

MergeMode controls how to combine two different schemas. Union is used for two independent services, Intersection for two different versions of the same service.

const (
	// Union computes a schema that is supported by the two services combined.
	//
	// A Union is used to to combine the schema of two independent services.
	// The proxy will split a GraphQL query to ask each service the fields
	// it knows about.
	//
	// Two schemas must be compatible: Any overlapping types (eg. a field that
	// is implemented by both services, or two input types) must be compatible.
	// In practice, this means types must be identical except for non-nil
	// modifiers.
	//
	// XXX: take intersection on ENUM values to not confuse a service with a
	// type it doesn't support?
	Union MergeMode = "union"

	// Intersection computes a schema that is supported by both services.
	//
	// An Intersection is used to combine two schemas of different versions
	// of the same service. During a deploy, only of two versions might be
	// available, and so queries must be compatible with both schemas.
	//
	// Intersection computes a schema that can be executed by both services.
	// It only includes types and fields (etc.) exported by both services.
	// Overlapping types must be compatible as in a Union merge.
	//
	// One surprise might be that newly added ENUM values or UNION types might
	// be returned by the merged schema.
	Intersection MergeMode = "intersection"
)

type Null

type Null struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Null) Descriptor

func (*Null) Descriptor() ([]byte, []int)

func (*Null) ProtoMessage

func (*Null) ProtoMessage()

func (*Null) Reset

func (m *Null) Reset()

func (*Null) String

func (m *Null) String() string

func (*Null) XXX_DiscardUnknown

func (m *Null) XXX_DiscardUnknown()

func (*Null) XXX_Marshal

func (m *Null) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Null) XXX_Merge

func (m *Null) XXX_Merge(src proto.Message)

func (*Null) XXX_Size

func (m *Null) XXX_Size() int

func (*Null) XXX_Unmarshal

func (m *Null) XXX_Unmarshal(b []byte) error

type PathStep

type PathStep struct {
	Kind StepKind // StepKind is used to indicate the type of previous steps in the plan are
	Name string   // Name of the selection or type this path is nested on
}

PathStep represents a step in the path from the original query to a subquery that can be resolved on a single GraphQL server. Lets go through a few examples

If we have a selection type like the example below

previouspathstep {
 a: s1nest
}

The list of path steps should include {Kind: KindField, Name: "previouspathstep"} and {Kind: KindField, Name: "a"} to indicate this subquery is nested on "previouspathstep" and "a"

If we have a union type like the example below,

previouspathstep {
	... on Foo {
		name
	}
}

The list of path steps should include {Kind: KindField, Name: "previouspathstep"} and {Kind: KindType, Name: "Foo"} to indicate this subquery is nested on "previouspathstep" selection and the "Foo" type.

type Plan

type Plan struct {
	Path         []PathStep             // Pathstep defines what the steps this subplan is nested on
	Service      string                 // Service that resolves this path step
	Kind         string                 // Kind is either a query or mutation
	Type         string                 // Fn is the name of the object type each subplan is nested on
	SelectionSet *internal.SelectionSet // Selections that will be resolved in this part of the plan
	After        []*Plan                // Subplans from nested queries on this path
}

Plan breaks the query down into subqueries that can be resolved by a single graphql server

func ConvertRequest

func ConvertRequest(request *FederationRequest) *Plan

func MustPlan

func MustPlan(planner *Planner, param execution.Params) (*Plan, error)

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner is responsible for taking a query created a plan that will be used by the executor. This breaks every query into subqueries that can each be resolved by a single graphQLServer and describes what sub-queries need to be resolved first.

func NewPlaner

func NewPlaner(schema *SchemaWithFederationInfo) (*Planner, error)

type SchemaWithFederationInfo

type SchemaWithFederationInfo struct {
	Schema *internal.Schema
	// Fields is a map of fields to services which they belong to
	Fields map[*internal.Field]*FieldInfo
}

SchemaWithFederationInfo holds a system.Schema along with federtion-specific annotations per field.

func ConvertSchema

func ConvertSchema(schemas map[string]string) (*SchemaWithFederationInfo, error)

type Selection

type Selection struct {
	Name                 string        `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Alias                string        `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"`
	Args                 *any.Any      `protobuf:"bytes,3,opt,name=args,proto3" json:"args,omitempty"`
	SelectionSet         *SelectionSet `protobuf:"bytes,4,opt,name=selectionSet,proto3" json:"selectionSet,omitempty"`
	Directives           []*Directive  `protobuf:"bytes,5,rep,name=directives,proto3" json:"directives,omitempty"`
	Loc                  *Location     `protobuf:"bytes,6,opt,name=loc,proto3" json:"loc,omitempty"`
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

func (*Selection) Descriptor

func (*Selection) Descriptor() ([]byte, []int)

func (*Selection) GetAlias

func (m *Selection) GetAlias() string

func (*Selection) GetArgs

func (m *Selection) GetArgs() *any.Any

func (*Selection) GetDirectives

func (m *Selection) GetDirectives() []*Directive

func (*Selection) GetLoc

func (m *Selection) GetLoc() *Location

func (*Selection) GetName

func (m *Selection) GetName() string

func (*Selection) GetSelectionSet

func (m *Selection) GetSelectionSet() *SelectionSet

func (*Selection) ProtoMessage

func (*Selection) ProtoMessage()

func (*Selection) Reset

func (m *Selection) Reset()

func (*Selection) String

func (m *Selection) String() string

func (*Selection) XXX_DiscardUnknown

func (m *Selection) XXX_DiscardUnknown()

func (*Selection) XXX_Marshal

func (m *Selection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Selection) XXX_Merge

func (m *Selection) XXX_Merge(src proto.Message)

func (*Selection) XXX_Size

func (m *Selection) XXX_Size() int

func (*Selection) XXX_Unmarshal

func (m *Selection) XXX_Unmarshal(b []byte) error

type SelectionSet

type SelectionSet struct {
	Loc                  *Location         `protobuf:"bytes,1,opt,name=loc,proto3" json:"loc,omitempty"`
	Selections           []*Selection      `protobuf:"bytes,2,rep,name=selections,proto3" json:"selections,omitempty"`
	Fragments            []*FragmentSpread `protobuf:"bytes,3,rep,name=fragments,proto3" json:"fragments,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func ConvertToSelectionSet

func ConvertToSelectionSet(s *internal.SelectionSet) *SelectionSet

func (*SelectionSet) Descriptor

func (*SelectionSet) Descriptor() ([]byte, []int)

func (*SelectionSet) GetFragments

func (m *SelectionSet) GetFragments() []*FragmentSpread

func (*SelectionSet) GetLoc

func (m *SelectionSet) GetLoc() *Location

func (*SelectionSet) GetSelections

func (m *SelectionSet) GetSelections() []*Selection

func (*SelectionSet) ProtoMessage

func (*SelectionSet) ProtoMessage()

func (*SelectionSet) Reset

func (m *SelectionSet) Reset()

func (*SelectionSet) String

func (m *SelectionSet) String() string

func (*SelectionSet) XXX_DiscardUnknown

func (m *SelectionSet) XXX_DiscardUnknown()

func (*SelectionSet) XXX_Marshal

func (m *SelectionSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SelectionSet) XXX_Merge

func (m *SelectionSet) XXX_Merge(src proto.Message)

func (*SelectionSet) XXX_Size

func (m *SelectionSet) XXX_Size() int

func (*SelectionSet) XXX_Unmarshal

func (m *SelectionSet) XXX_Unmarshal(b []byte) error

type StepKind

type StepKind int
const (
	KindType StepKind = iota
	KindField
)

type UnimplementedFederationServiceServer

type UnimplementedFederationServiceServer struct {
}

UnimplementedFederationServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedFederationServiceServer) Execute

func (*UnimplementedFederationServiceServer) Introspection

func (*UnimplementedFederationServiceServer) Subscription

Jump to

Keyboard shortcuts

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