diff --git a/packages/delegate/src/delegationBindings.ts b/packages/delegate/src/delegationBindings.ts index 23bffcc73ee..1eb05edc5a9 100644 --- a/packages/delegate/src/delegationBindings.ts +++ b/packages/delegate/src/delegationBindings.ts @@ -1,4 +1,4 @@ -import { assertSome, Maybe } from '@graphql-tools/utils'; +import { Maybe } from '@graphql-tools/utils'; import { Transform, StitchingInfo, DelegationContext } from './types'; import AddSelectionSets from './transforms/AddSelectionSets'; @@ -18,8 +18,6 @@ export function defaultDelegationBinding( const stitchingInfo: Maybe = info?.schema.extensions?.['stitchingInfo']; if (stitchingInfo != null) { - assertSome(stitchingInfo.selectionSetsByType); - assertSome(stitchingInfo.dynamicSelectionSetsByField); delegationTransforms = delegationTransforms.concat([ new ExpandAbstractTypes(), new AddSelectionSets( diff --git a/packages/delegate/src/types.ts b/packages/delegate/src/types.ts index cc2a614414d..1e12ddd9592 100644 --- a/packages/delegate/src/types.ts +++ b/packages/delegate/src/types.ts @@ -188,9 +188,9 @@ export type MergedTypeResolver> = ( export interface StitchingInfo> { subschemaMap: Map, Subschema>; - selectionSetsByType: Record | undefined; + selectionSetsByType: Record; selectionSetsByField: Record>; - dynamicSelectionSetsByField: Record SelectionSetNode>>> | undefined; + dynamicSelectionSetsByField: Record SelectionSetNode>>>; mergedTypes: Record>; } diff --git a/packages/stitch/src/stitchingInfo.ts b/packages/stitch/src/stitchingInfo.ts index 8f048d2b5dd..da5ace90a1c 100644 --- a/packages/stitch/src/stitchingInfo.ts +++ b/packages/stitch/src/stitchingInfo.ts @@ -76,9 +76,9 @@ export function createStitchingInfo>( return { subschemaMap, - selectionSetsByType: undefined, + selectionSetsByType: Object.create(null), selectionSetsByField, - dynamicSelectionSetsByField: undefined, + dynamicSelectionSetsByField: Object.create(null), mergedTypes, }; } @@ -227,7 +227,8 @@ export function completeStitchingInfo>( resolvers: IResolvers, schema: GraphQLSchema ): StitchingInfo { - const selectionSetsByType = Object.create(null); + const { selectionSetsByType, selectionSetsByField, dynamicSelectionSetsByField } = stitchingInfo; + const rootTypes = [schema.getQueryType(), schema.getMutationType()]; for (const rootType of rootTypes) { if (rootType) { @@ -235,9 +236,6 @@ export function completeStitchingInfo>( } } - const selectionSetsByField = stitchingInfo.selectionSetsByField; - const dynamicSelectionSetsByField = Object.create(null); - for (const typeName in resolvers) { const type = resolvers[typeName]; if (isScalarType(type)) { @@ -288,10 +286,6 @@ export function completeStitchingInfo>( } } - stitchingInfo.selectionSetsByType = selectionSetsByType; - stitchingInfo.selectionSetsByField = selectionSetsByField; - stitchingInfo.dynamicSelectionSetsByField = dynamicSelectionSetsByField; - return stitchingInfo; }