@graphql-tools/federation
Classes
Interfaces
- FederationSubschemaConfig
- GetStitchedSchemaFromSupergraphSdlOpts
- GetStitchingOptionsFromSupergraphSdlOpts
Type Aliases
- FetchError
- FetchSupergraphSdlFromManagedFederationOpts
- GetStitchedSchemaFromManagedFederationOpts
- RouterConfig
- RouterConfigWithSchema
- SupergraphSchemaManagerOptions
- Unchanged
Variables
Functions
- buildSubgraphSchema
- ensureSupergraphSDLAst
- federationSubschemaTransformer
- fetchSupergraphSdlFromManagedFederation
- filterInternalFieldsAndTypes
- getArgsFromKeysForFederation
- getCacheKeyFnFromKey
- getKeyFnForFederation
- getKeyForFederation
- getNamedTypeNode
- getStitchedSchemaFromManagedFederation
- getStitchedSchemaFromSupergraphSdl
- getStitchedSchemaWithUrls
- getStitchingOptionsFromSupergraphSdl
- getSubschemaForFederationWithExecutor
- getSubschemaForFederationWithSchema
- getSubschemaForFederationWithTypeDefs
- getSubschemaForFederationWithURL
- projectDataSelectionSet
Type Aliases
FetchError
Ƭ FetchError: Object
Type declaration
Name | Type | Description |
---|---|---|
error | { code : string ; message : string } | The fetch error reported by the up link. This means it’s not the local fetch error. Local fetch errors are thrown as exceptions. |
error.code | string | - |
error.message | string | - |
minDelaySeconds | number | The minimum delay in seconds to wait before trying to fetch this supergraph again. |
Defined in
packages/federation/src/managed-federation.ts:86
FetchSupergraphSdlFromManagedFederationOpts
Ƭ FetchSupergraphSdlFromManagedFederationOpts: Object
Type declaration
Name | Type | Description |
---|---|---|
apiKey? | string | The API key to use to authenticate with the managed federation up link. It needs at least the service:read permission. If not provided, APOLLO_KEY environment variable will be used instead. Learn how to create an API key |
fetch? | FetchFn | The fetch implementation to use. Default: global.fetch |
graphRef? | string | The graph ref of the managed federation graph. It is composed of the graph ID and the variant (<YOUR_GRAPH_ID>@<VARIANT> ). If not provided, APOLLO_GRAPH_REF environment variable is used. You can find a a graph’s ref at the top of its Schema Reference page in Apollo Studio. |
lastSeenId? | string | The ID of the last fetched supergraph. If provided, a supergraph is returned only if the managed supergraph have changed. |
loggerByMessageLevel? | typeof DEFAULT_MESSAGE_LOGGER | Up link can send back messages meant to be logged alongside the supergraph SDL. By default, the console is used. |
upLink? | string | The URL of the managed federation up link. When retrying after a failure, you should cycle through the default up links using this option. Uplinks are available in DEFAULT_UPLINKS constant. This options can also be defined using the APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT environment variable. It should be a comma separated list of up links, but only the first one will be used. Default: ‘https://uplink.api.apollographql.com/’ (Apollo’s managed federation up link on GCP) Alternative: ‘https://aws.uplink.api.apollographql.com/’ (Apollo’s managed federation up link on AWS) |
Defined in
packages/federation/src/managed-federation.ts:11
GetStitchedSchemaFromManagedFederationOpts
Ƭ GetStitchedSchemaFromManagedFederationOpts: FetchSupergraphSdlFromManagedFederationOpts
& Omit
<GetStitchedSchemaFromSupergraphSdlOpts
, "supergraphSdl"
>
Defined in
packages/federation/src/managed-federation.ts:242
RouterConfig
Ƭ RouterConfig: Object
Type declaration
Name | Type | Description |
---|---|---|
id | string | The ID of the supergraph. Should be used as lastSeenId in the next fetch. |
minDelaySeconds | number | The minimum delay in seconds to wait before trying to fetch this supergraph again. |
supergraphSdl | string | The supergraph SDL. |
Defined in
packages/federation/src/managed-federation.ts:60
RouterConfigWithSchema
Ƭ RouterConfigWithSchema: RouterConfig
& { schema
: GraphQLSchema
}
Defined in
packages/federation/src/managed-federation.ts:246
SupergraphSchemaManagerOptions
Ƭ SupergraphSchemaManagerOptions: Omit
<GetStitchedSchemaFromManagedFederationOpts
, "lastSeenId"
> & { maxRetries?
: number
; minDelaySeconds?
: number
; retryDelaySeconds?
: number
}
Defined in
packages/federation/src/managed-federation.ts:297
Unchanged
Ƭ Unchanged: Object
Type declaration
Name | Type | Description |
---|---|---|
id | string | The ID of the supergraph. Should be used as lastSeenId in the next fetch. |
minDelaySeconds | number | The minimum delay in seconds to wait before trying to fetch this supergraph again. |
Defined in
packages/federation/src/managed-federation.ts:75
Variables
DEFAULT_UPLINKS
• Const
DEFAULT_UPLINKS: string
[]
The default managed federation up links. In case of failure, you should try to cycle through these up links.
The first one is Apollo’s managed federation up link on GCP, the second one is on AWS.
Defined in
packages/federation/src/managed-federation.ts:116
SubgraphBaseSDL
• Const
SubgraphBaseSDL: "\n scalar _Any\n scalar _FieldSet\n scalar link__Import\n\n enum link__Purpose {\n SECURITY\n EXECUTION\n }\n\n type _Service {\n sdl: String!\n }\n\n type Query {\n _service: _Service!\n }\n\n directive @external on FIELD_DEFINITION | OBJECT\n directive @requires(fields: _FieldSet!) on FIELD_DEFINITION\n directive @provides(fields: _FieldSet!) on FIELD_DEFINITION\n directive @key(fields: _FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE\n directive @link(\n url: String!\n as: String\n for: link__Purpose\n import: [link__Import]\n ) repeatable on SCHEMA\n directive @shareable repeatable on OBJECT | FIELD_DEFINITION\n directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION\n directive @tag(\n name: String!\n ) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION\n directive @override(from: String!) on FIELD_DEFINITION\n directive @composeDirective(name: String!) repeatable on SCHEMA\n\n directive @extends on OBJECT | INTERFACE\n"
Defined in
packages/federation/src/subgraph.ts:14
SubgraphSDLQuery
• Const
SubgraphSDLQuery: "\n query SubgraphSDL {\n _service {\n sdl\n }\n }\n"
Defined in
packages/federation/src/gateway.ts:31
Functions
buildSubgraphSchema
▸ buildSubgraphSchema<TContext
>(optsOrModules
): GraphQLSchema
Type parameters
Name | Type |
---|---|
TContext | any |
Parameters
Name | Type |
---|---|
optsOrModules | IExecutableSchemaDefinition <TContext > | Pick <IExecutableSchemaDefinition <TContext >, "resolvers" | "typeDefs" >[] |
Returns
GraphQLSchema
Defined in
packages/federation/src/subgraph.ts:53
ensureSupergraphSDLAst
▸ ensureSupergraphSDLAst(supergraphSdl
): DocumentNode
Parameters
Name | Type |
---|---|
supergraphSdl | string | DocumentNode |
Returns
DocumentNode
Defined in
packages/federation/src/supergraph.ts:68
federationSubschemaTransformer
▸ federationSubschemaTransformer(subschemaConfig
): SubschemaConfig
<any
, any
, any
, Record
<string
, any
>> | SubschemaConfig
<any
, any
, any
, Record
<string
, any
>>[]
Parameters
Name | Type |
---|---|
subschemaConfig | SubschemaConfig <any , any , any , Record <string , any >> |
Returns
SubschemaConfig
<any
, any
, any
, Record
<string
, any
>> | SubschemaConfig
<any
, any
, any
, Record
<string
, any
>>[]
Defined in
packages/federation/src/gateway.ts:220
fetchSupergraphSdlFromManagedFederation
▸ fetchSupergraphSdlFromManagedFederation(options?
): Promise
<RouterConfig
| Unchanged
| FetchError
>
Fetches the supergraph SDL from a managed federation GraphOS up link.
Parameters
Name | Type |
---|---|
options | FetchSupergraphSdlFromManagedFederationOpts |
Returns
Promise
<RouterConfig
| Unchanged
| FetchError
>
An object with the supergraph SDL when possible. It also includes metadata to handle polling and retry logic.
If `lastSeenId` is provided and the supergraph has not changed, `supergraphSdl` is not present.
If The up link report a fetch error (which is not a local fetch error), it will be returned along with polling/retry metadata.
Any local fetch error will be thrown as an exception.
Throws
When the fetch fails or the response is not a valid.
Defined in
packages/federation/src/managed-federation.ts:132
filterInternalFieldsAndTypes
▸ filterInternalFieldsAndTypes(finalSchema
): GraphQLSchema
Parameters
Name | Type |
---|---|
finalSchema | GraphQLSchema |
Returns
GraphQLSchema
Defined in
packages/federation/src/utils.ts:123
getArgsFromKeysForFederation
▸ getArgsFromKeysForFederation(representations
): Object
Parameters
Name | Type |
---|---|
representations | readonly any [] |
Returns
Object
Name | Type |
---|---|
representations | readonly any [] |
Defined in
packages/federation/src/utils.ts:4
getCacheKeyFnFromKey
▸ getCacheKeyFnFromKey(key
): (root
: any
) => any
Parameters
Name | Type |
---|---|
key | string |
Returns
fn
▸ (root
): any
Parameters
Name | Type |
---|---|
root | any |
Returns
any
Defined in
packages/federation/src/utils.ts:102
getKeyFnForFederation
▸ getKeyFnForFederation(typeName
, keys
): (root
: any
) => any
Parameters
Name | Type |
---|---|
typeName | string |
keys | string [] |
Returns
fn
▸ (root
): any
Parameters
Name | Type |
---|---|
root | any |
Returns
any
Defined in
packages/federation/src/utils.ts:66
getKeyForFederation
▸ getKeyForFederation<TRoot
>(root
): TRoot
Type parameters
Name |
---|
TRoot |
Parameters
Name | Type |
---|---|
root | TRoot |
Returns
TRoot
Defined in
packages/federation/src/utils.ts:8
getNamedTypeNode
▸ getNamedTypeNode(typeNode
): NamedTypeNode
Parameters
Name | Type |
---|---|
typeNode | TypeNode |
Returns
NamedTypeNode
Defined in
packages/federation/src/utils.ts:174
getStitchedSchemaFromManagedFederation
▸ getStitchedSchemaFromManagedFederation(options
): Promise
<RouterConfigWithSchema
| FetchError
| Unchanged
>
Fetches the supergraph SDL from a managed federation GraphOS up link and stitches it into an executable schema.
Parameters
Name | Type |
---|---|
options | GetStitchedSchemaFromManagedFederationOpts |
Returns
Promise
<RouterConfigWithSchema
| FetchError
| Unchanged
>
An object with the supergraph SDL and the stitched schema when possible. It also includes metadata to handle polling and retry logic.
If `lastSeenId` is provided and the supergraph has not changed, `supergraphSdl` is not present.
If The up link report a fetch error (which is not a local fetch error), it will be returned along with polling/retry metadata.
Any local fetch error will be thrown as an exception.
Throws
When the fetch fails, the response is not a valid or the stitching fails.
Defined in
packages/federation/src/managed-federation.ts:264
getStitchedSchemaFromSupergraphSdl
▸ getStitchedSchemaFromSupergraphSdl(opts
): GraphQLSchema
Parameters
Name | Type |
---|---|
opts | GetStitchedSchemaFromSupergraphSdlOpts |
Returns
GraphQLSchema
Defined in
packages/federation/src/supergraph.ts:1212
getStitchedSchemaWithUrls
▸ getStitchedSchemaWithUrls(configs
): Promise
<GraphQLSchema
>
Parameters
Name | Type |
---|---|
configs | HTTPExecutorOptions [] |
Returns
Promise
<GraphQLSchema
>
Defined in
packages/federation/src/gateway.ts:210
getStitchingOptionsFromSupergraphSdl
▸ getStitchingOptionsFromSupergraphSdl(opts
): Object
Parameters
Name | Type |
---|---|
opts | GetStitchingOptionsFromSupergraphSdlOpts |
Returns
Object
Name | Type |
---|---|
assumeValid | boolean |
assumeValidSDL | boolean |
subschemas | SubschemaConfig <any , any , any , Record <string , any >>[] |
typeDefs | DocumentNode |
typeMergingOptions | { fieldConfigMerger : (candidates : MergeFieldConfigCandidate <Record <string , any >>[]) => GraphQLFieldConfig <any , Record <string , any >, any > ; useNonNullableFieldOnConflict : boolean = true; validationSettings : { validationLevel : ValidationLevel = ValidationLevel.Off } } |
typeMergingOptions.fieldConfigMerger | (candidates : MergeFieldConfigCandidate <Record <string , any >>[]) => GraphQLFieldConfig <any , Record <string , any >, any > |
typeMergingOptions.useNonNullableFieldOnConflict | boolean |
typeMergingOptions.validationSettings | { validationLevel : ValidationLevel = ValidationLevel.Off } |
typeMergingOptions.validationSettings.validationLevel | ValidationLevel |
Defined in
packages/federation/src/supergraph.ts:112
getSubschemaForFederationWithExecutor
▸ getSubschemaForFederationWithExecutor(executor
): Promise
<{ batch?
: boolean
; batchingOptions?
: BatchingOptions
<any
, any
, any
> ; createProxyingResolver?
: CreateProxyingResolverFn
<Record
<string
, any
>> ; executor
: Executor
; merge?
: Record
<string
, MergedTypeConfig
<any
, any
, Record
<string
, any
>>> ; name?
: string
; rootValue?
: any
; schema
: GraphQLSchema
; transforms?
: Transform
<any
, Record
<string
, any
>>[] }>
Parameters
Name | Type |
---|---|
executor | Executor |
Returns
Promise
<{ batch?
: boolean
; batchingOptions?
: BatchingOptions
<any
, any
, any
> ; createProxyingResolver?
: CreateProxyingResolverFn
<Record
<string
, any
>> ; executor
: Executor
; merge?
: Record
<string
, MergedTypeConfig
<any
, any
, Record
<string
, any
>>> ; name?
: string
; rootValue?
: any
; schema
: GraphQLSchema
; transforms?
: Transform
<any
, Record
<string
, any
>>[] }>
Defined in
packages/federation/src/gateway.ts:181
getSubschemaForFederationWithSchema
▸ getSubschemaForFederationWithSchema(schema
): Promise
<{ batch?
: boolean
; batchingOptions?
: BatchingOptions
<any
, any
, any
> ; createProxyingResolver?
: CreateProxyingResolverFn
<Record
<string
, any
>> ; executor
: Executor
; merge?
: Record
<string
, MergedTypeConfig
<any
, any
, Record
<string
, any
>>> ; name?
: string
; rootValue?
: any
; schema
: GraphQLSchema
; transforms?
: Transform
<any
, Record
<string
, any
>>[] }>
Parameters
Name | Type |
---|---|
schema | GraphQLSchema |
Returns
Promise
<{ batch?
: boolean
; batchingOptions?
: BatchingOptions
<any
, any
, any
> ; createProxyingResolver?
: CreateProxyingResolverFn
<Record
<string
, any
>> ; executor
: Executor
; merge?
: Record
<string
, MergedTypeConfig
<any
, any
, Record
<string
, any
>>> ; name?
: string
; rootValue?
: any
; schema
: GraphQLSchema
; transforms?
: Transform
<any
, Record
<string
, any
>>[] }>
Defined in
packages/federation/src/gateway.ts:205
getSubschemaForFederationWithTypeDefs
▸ getSubschemaForFederationWithTypeDefs(typeDefs
): SubschemaConfig
Parameters
Name | Type |
---|---|
typeDefs | DocumentNode |
Returns
Defined in
packages/federation/src/gateway.ts:50
getSubschemaForFederationWithURL
▸ getSubschemaForFederationWithURL(config
): Promise
<SubschemaConfig
>
Parameters
Name | Type |
---|---|
config | HTTPExecutorOptions |
Returns
Promise
<SubschemaConfig
>
Defined in
packages/federation/src/gateway.ts:39
projectDataSelectionSet
▸ projectDataSelectionSet(data
, selectionSet?
): any
Parameters
Name | Type |
---|---|
data | any |
selectionSet? | SelectionSetNode |
Returns
any