Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cli/src/commands/router/commands/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default (opts: BaseCommandOptions) => {
'--disable-resolvability-validation',
'This flag will disable the validation for whether all nodes of the federated graph are resolvable. Do NOT use unless troubleshooting.',
);
command.option('--ignore-external-keys', 'This flag ignores errors related to true external entity keys.');

command.action(async (options) => {
const inputFile = resolve(options.input);
Expand Down Expand Up @@ -207,7 +208,10 @@ export default (opts: BaseCommandOptions) => {
definitions: parse(s.sdl),
};
}),
options.disableResolvabilityValidation,
{
disableResolvabilityValidation: options.disableResolvabilityValidation,
ignoreExternalKeys: options.ignoreExternalKeys,
},
);

if (!result.success) {
Expand Down Expand Up @@ -587,7 +591,10 @@ async function buildFeatureFlagsConfig(
url: normalizeURL(s.routingUrl),
definitions: parse(s.sdl),
})),
options.disableResolvabilityValidation,
{
disableResolvabilityValidation: options.disableResolvabilityValidation,
ignoreExternalKeys: options.ignoreExternalKeys,
},
);

if (!featureResult.success) {
Expand Down
5 changes: 3 additions & 2 deletions cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/named */
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import {
CompositionOptions,
federateSubgraphs,
FederationResult,
ROUTER_COMPATIBILITY_VERSION_ONE,
Expand Down Expand Up @@ -179,9 +180,9 @@ export const introspectSubgraph = async ({
/**
* Composes a list of subgraphs into a single schema.
*/
export function composeSubgraphs(subgraphs: Subgraph[], disableResolvabilityValidation?: boolean): FederationResult {
export function composeSubgraphs(subgraphs: Subgraph[], options?: CompositionOptions): FederationResult {
// @TODO get router compatibility version programmatically
return federateSubgraphs({ disableResolvabilityValidation, subgraphs, version: ROUTER_COMPATIBILITY_VERSION_ONE });
return federateSubgraphs({ options, subgraphs, version: ROUTER_COMPATIBILITY_VERSION_ONE });
}

export type ConfigData = Partial<KeycloakToken & { organizationSlug: string; lastUpdateCheck: number }>;
Expand Down
2 changes: 1 addition & 1 deletion cli/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Configure Vitest (https://vitest.dev/config/)

import { defineConfig } from "vitest/config";
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
Expand Down
264 changes: 132 additions & 132 deletions composition-go/index.global.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions composition/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ignorePatterns": ["*.d.ts"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import"],
"rules": {
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"fixStyle": "inline-type-imports"
}
],
"import/no-duplicates": ["error", { "prefer-inline": true }],
"object-curly-spacing": ["error", "always"]
}
}
2 changes: 1 addition & 1 deletion composition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:core": "vitest run --exclude ./tests/unstaged-tests",
"test:coverage": "vitest run --coverage",
"lint": "prettier --check .",
"lint:fix": "pnpm format",
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && pnpm format",
"format": "prettier -w -c .",
"postversion": "node ./scripts/get-composition-version.mjs"
},
Expand Down
46 changes: 23 additions & 23 deletions composition/src/ast/utils.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import {
ArgumentNode,
DocumentNode,
EnumTypeDefinitionNode,
EnumTypeExtensionNode,
FieldNode,
InputObjectTypeDefinitionNode,
InputObjectTypeExtensionNode,
InterfaceTypeDefinitionNode,
InterfaceTypeExtensionNode,
type ArgumentNode,
type DocumentNode,
type EnumTypeDefinitionNode,
type EnumTypeExtensionNode,
type FieldNode,
type InputObjectTypeDefinitionNode,
type InputObjectTypeExtensionNode,
type InterfaceTypeDefinitionNode,
type InterfaceTypeExtensionNode,
Kind,
NamedTypeNode,
NameNode,
ObjectTypeDefinitionNode,
ObjectTypeExtensionNode,
type NamedTypeNode,
type NameNode,
type ObjectTypeDefinitionNode,
type ObjectTypeExtensionNode,
OperationTypeNode,
parse as graphqlParse,
ScalarTypeDefinitionNode,
ScalarTypeExtensionNode,
SchemaDefinitionNode,
SchemaExtensionNode,
SelectionNode,
SelectionSetNode,
StringValueNode,
UnionTypeDefinitionNode,
UnionTypeExtensionNode,
type ScalarTypeDefinitionNode,
type ScalarTypeExtensionNode,
type SchemaDefinitionNode,
type SchemaExtensionNode,
type SelectionNode,
type SelectionSetNode,
type StringValueNode,
type UnionTypeDefinitionNode,
type UnionTypeExtensionNode,
} from 'graphql';
import { CompositeOutputNode } from '../schema-building/ast';
import { type CompositeOutputNode } from '../schema-building/ast';
import {
ARGUMENT_DEFINITION_UPPER,
ENUM_UPPER,
Expand Down
4 changes: 2 additions & 2 deletions composition/src/buildASTSchema/buildASTSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DocumentNode, GraphQLSchema, specifiedDirectives } from 'graphql';
import { type DocumentNode, GraphQLSchema, specifiedDirectives } from 'graphql';
import { assertValidSDL } from 'graphql/validation/validate';
import { extendSchemaImpl } from './extendSchema';
import { GraphQLSchemaValidationOptions } from 'graphql/type/schema';
import { type GraphQLSchemaValidationOptions } from 'graphql/type/schema';

export interface BuildASTSchemaOptions extends GraphQLSchemaValidationOptions {
addInvalidExtensionOrphans?: boolean;
Expand Down
70 changes: 35 additions & 35 deletions composition/src/buildASTSchema/extendSchema.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
import {
DirectiveDefinitionNode,
DocumentNode,
EnumTypeDefinitionNode,
EnumTypeExtensionNode,
EnumValueDefinitionNode,
FieldDefinitionNode,
GraphQLArgumentConfig,
type DirectiveDefinitionNode,
type DocumentNode,
type EnumTypeDefinitionNode,
type EnumTypeExtensionNode,
type EnumValueDefinitionNode,
type FieldDefinitionNode,
getDirectiveValues,
type GraphQLArgumentConfig,
GraphQLDeprecatedDirective,
GraphQLDirective,
GraphQLEnumType,
GraphQLEnumValueConfigMap,
GraphQLFieldConfig,
GraphQLFieldConfigArgumentMap,
GraphQLFieldConfigMap,
GraphQLInputFieldConfigMap,
type GraphQLEnumValueConfigMap,
type GraphQLFieldConfig,
type GraphQLFieldConfigArgumentMap,
type GraphQLFieldConfigMap,
type GraphQLInputFieldConfigMap,
GraphQLInputObjectType,
GraphQLInterfaceType,
GraphQLList,
GraphQLNamedType,
type GraphQLNamedType,
GraphQLNonNull,
GraphQLObjectType,
GraphQLScalarType,
GraphQLSpecifiedByDirective,
GraphQLType,
type GraphQLType,
GraphQLUnionType,
InputObjectTypeDefinitionNode,
InputObjectTypeExtensionNode,
InputValueDefinitionNode,
InterfaceTypeDefinitionNode,
InterfaceTypeExtensionNode,
Kind,
NamedTypeNode,
ObjectTypeDefinitionNode,
ObjectTypeExtensionNode,
ScalarTypeDefinitionNode,
ScalarTypeExtensionNode,
SchemaDefinitionNode,
SchemaExtensionNode,
TypeDefinitionNode,
TypeNode,
UnionTypeDefinitionNode,
UnionTypeExtensionNode,
getDirectiveValues,
type InputObjectTypeDefinitionNode,
type InputObjectTypeExtensionNode,
type InputValueDefinitionNode,
type InterfaceTypeDefinitionNode,
type InterfaceTypeExtensionNode,
introspectionTypes,
isEnumType,
isInputObjectType,
Expand All @@ -54,12 +42,24 @@ import {
isSpecifiedDirective,
isSpecifiedScalarType,
isUnionType,
Kind,
type NamedTypeNode,
type ObjectTypeDefinitionNode,
type ObjectTypeExtensionNode,
type ScalarTypeDefinitionNode,
type ScalarTypeExtensionNode,
type SchemaDefinitionNode,
type SchemaExtensionNode,
specifiedScalarTypes,
type TypeDefinitionNode,
type TypeNode,
type UnionTypeDefinitionNode,
type UnionTypeExtensionNode,
valueFromAST,
} from 'graphql';
import { GraphQLSchemaNormalizedConfig } from 'graphql/type/schema';
import { BuildASTSchemaOptions } from './buildASTSchema';
import { Maybe } from 'graphql/jsutils/Maybe';
import { type GraphQLSchemaNormalizedConfig } from 'graphql/type/schema';
import { type BuildASTSchemaOptions } from './buildASTSchema';
import { type Maybe } from 'graphql/jsutils/Maybe';

export class AccumulatorMap<K, T> extends Map<K, Array<T>> {
get [Symbol.toStringTag]() {
Expand Down
38 changes: 21 additions & 17 deletions composition/src/errors/errors.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Kind, OperationTypeNode } from 'graphql';
import { Kind, type OperationTypeNode } from 'graphql';
import {
EntityInterfaceFederationData,
FieldData,
InputValueData,
ObjectDefinitionData,
type EntityInterfaceFederationData,
type FieldData,
type InputValueData,
type ObjectDefinitionData,
} from '../schema-building/types';
import {
IncompatibleMergedTypesErrorParams,
IncompatibleParentTypeMergeErrorParams,
IncompatibleTypeWithProvidesErrorMessageParams,
InvalidNamedTypeErrorParams,
InvalidRootTypeFieldEventsDirectiveData,
NonExternalConditionalFieldErrorParams,
OneOfRequiredFieldsErrorParams,
SemanticNonNullLevelsIndexOutOfBoundsErrorParams,
SemanticNonNullLevelsNonNullErrorParams,
type IncompatibleMergedTypesErrorParams,
type IncompatibleParentTypeMergeErrorParams,
type IncompatibleTypeWithProvidesErrorMessageParams,
type InvalidNamedTypeErrorParams,
type InvalidRootTypeFieldEventsDirectiveData,
type NonExternalConditionalFieldErrorParams,
type OneOfRequiredFieldsErrorParams,
type SemanticNonNullLevelsIndexOutOfBoundsErrorParams,
type SemanticNonNullLevelsNonNullErrorParams,
} from './types';
import { UnresolvableFieldData } from '../resolvability-graph/utils/utils';
import { type UnresolvableFieldData } from '../resolvability-graph/utils/utils';
import {
AND_UPPER,
ARGUMENT,
Expand All @@ -41,10 +41,14 @@ import {
} from '../utils/string-constants';
import { MAX_SUBSCRIPTION_FILTER_DEPTH, MAXIMUM_TYPE_NESTING } from '../utils/integer-constants';
import { getEntriesNotInHashSet, getOrThrowError, kindToNodeType, numberToOrdinal } from '../utils/utils';
import { ImplementationErrors, InvalidEntityInterface, InvalidRequiredInputValueData } from '../utils/types';
import {
type ImplementationErrors,
type InvalidEntityInterface,
type InvalidRequiredInputValueData,
} from '../utils/types';
import { isFieldData } from '../schema-building/utils';
import { printTypeNode } from '@graphql-tools/merge';
import { NodeType, TypeName } from '../types/types';
import { type NodeType, type TypeName } from '../types/types';

export const minimumSubgraphRequirementError = new Error('At least one subgraph is required for federation.');

Expand Down
4 changes: 2 additions & 2 deletions composition/src/errors/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FieldData, InputValueData, ParentDefinitionData } from '../schema-building/types';
import { DirectiveName, FieldName, SubgraphName, TypeName } from '../types/types';
import { type FieldData, type InputValueData, type ParentDefinitionData } from '../schema-building/types';
import { type DirectiveName, type FieldName, type SubgraphName, type TypeName } from '../types/types';

export type InvalidRootTypeFieldEventsDirectiveData = {
definesDirectives: boolean;
Expand Down
25 changes: 12 additions & 13 deletions composition/src/federation/federation.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
import {
FederateSubgraphsContractParams,
FederateSubgraphsParams,
FederateSubgraphsWithContractsParams,
FederationResult,
FederationResultWithContracts,
} from './types';
import { type FederationResult, type FederationResultWithContracts } from './types';
import {
federateSubgraphs as federateSubgraphsV1,
federateSubgraphsContract as federateSubgraphsContractV1,
federateSubgraphsWithContracts as federateSubgraphsWithContractsV1,
} from '../v1/federation/federation-factory';
import { ROUTER_COMPATIBILITY_VERSION_ONE } from '../router-compatibility-version/router-compatibility-version';
import {
type FederateSubgraphsContractParams,
type FederateSubgraphsParams,
type FederateSubgraphsWithContractsParams,
} from './params';

export function federateSubgraphs({
disableResolvabilityValidation,
options,
subgraphs,
version = ROUTER_COMPATIBILITY_VERSION_ONE,
}: FederateSubgraphsParams): FederationResult {
switch (version) {
default: {
return federateSubgraphsV1({ disableResolvabilityValidation, subgraphs });
return federateSubgraphsV1({ options, subgraphs });
}
}
}

// the flow when publishing a subgraph that also has contracts
export function federateSubgraphsWithContracts({
disableResolvabilityValidation,
options,
subgraphs,
tagOptionsByContractName,
version = ROUTER_COMPATIBILITY_VERSION_ONE,
}: FederateSubgraphsWithContractsParams): FederationResultWithContracts {
switch (version) {
default: {
return federateSubgraphsWithContractsV1({ disableResolvabilityValidation, subgraphs, tagOptionsByContractName });
return federateSubgraphsWithContractsV1({ options, subgraphs, tagOptionsByContractName });
}
}
}

export function federateSubgraphsContract({
contractTagOptions,
disableResolvabilityValidation,
options,
subgraphs,
version = ROUTER_COMPATIBILITY_VERSION_ONE,
}: FederateSubgraphsContractParams): FederationResult {
switch (version) {
default: {
return federateSubgraphsContractV1({ disableResolvabilityValidation, subgraphs, contractTagOptions });
return federateSubgraphsContractV1({ contractTagOptions, options, subgraphs });
}
}
}
Loading
Loading