Skip to content

Commit

Permalink
Revert to skipping missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer committed Jul 13, 2021
1 parent e970261 commit 89f7eda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
19 changes: 8 additions & 11 deletions federation-js/src/composition/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
import { validateSDL } from 'graphql/validation/validate';
import { compositionRules } from './rules';
import { printSupergraphSdl } from '../service/printSupergraphSdl';
import { mapGetOrSet, mapValues, filterMap } from '../utilities';
import { mapGetOrSet, mapValues } from '../utilities';

const EmptyQueryDefinition = {
kind: Kind.OBJECT_TYPE_DEFINITION,
Expand Down Expand Up @@ -677,7 +677,12 @@ export function addFederationMetadataToSchemaNodes({
}

for (const [typeName, fieldsToDirectivesMap] of typeNameToFieldDirectivesMap.entries()) {
const type = schema.getType(typeName) as GraphQLObjectType;
// It's plausible we're dealing with an incomplete schema here which might not
// account for all the types we saw when inspecting SDL. In the case that a
// type is extended with no base definition anywhere, it won't exist in the schema.
// There will be relevant composition errors for that case.
const type = schema.getType(typeName) as GraphQLObjectType | undefined;
if (!type) continue;

for (const [
fieldName,
Expand Down Expand Up @@ -762,22 +767,14 @@ export function composeServices(services: ServiceDefinition[]): CompositionResul

schema = lexicographicSortSchema(schema);

// Now that we have a constructed schema, we can filter this map based on types
// that made it into the schema successfully. Types that didn't make it into the
// schema will have related composition errors.
const filteredTypeNameToFieldDirectivesMap = filterMap(
typeNameToFieldDirectivesMap,
(typeName) => !!schema.getType(typeName),
);

addFederationMetadataToSchemaNodes({
schema,
typeToServiceMap,
externalFields,
keyDirectivesMap,
valueTypes,
directiveDefinitionsMap,
typeNameToFieldDirectivesMap: filteredTypeNameToFieldDirectivesMap,
typeNameToFieldDirectivesMap,
});

if (errors.length > 0) {
Expand Down
14 changes: 0 additions & 14 deletions federation-js/src/utilities/filterMap.ts

This file was deleted.

1 change: 0 additions & 1 deletion federation-js/src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export { assert } from './assert';
export { isNotNullOrUndefined } from './isNotNullOrUndefined';
export { mapGetOrSet } from './mapGetOrSet';
export { mapValues } from './mapValues';
export { filterMap } from './filterMap';

0 comments on commit 89f7eda

Please sign in to comment.