diff --git a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts index 814b5bc9eb0..64ca9b25e00 100644 --- a/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts +++ b/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts @@ -1304,8 +1304,10 @@ export class BaseResolversVisitor< if (resolverType.baseGeneratedTypename) { userDefinedTypes[schemaTypeName] = { name: resolverType.baseGeneratedTypename, - federation: resolverType.federation, }; + if (resolverType.federation) { + userDefinedTypes[schemaTypeName].federation = resolverType.federation; + } } return indent(this.formatRootResolver(schemaTypeName, resolverType.typename, declarationKind)); diff --git a/packages/plugins/typescript/resolvers/tests/ts-resolvers.federation.spec.ts b/packages/plugins/typescript/resolvers/tests/ts-resolvers.federation.spec.ts index 0941a774261..a70081fd926 100644 --- a/packages/plugins/typescript/resolvers/tests/ts-resolvers.federation.spec.ts +++ b/packages/plugins/typescript/resolvers/tests/ts-resolvers.federation.spec.ts @@ -734,61 +734,64 @@ describe('TypeScript Resolvers Plugin + Apollo Federation', () => { expect(result.meta?.generatedResolverTypes).toMatchInlineSnapshot(` Object { - "MultipleNonResolvable": Object { - "federation": Object { - "hasResolveReference": false, - }, - "name": "MultipleNonResolvableResolvers", + "resolversMap": Object { + "name": "Resolvers", }, - "MultipleResolvable": Object { - "federation": Object { - "hasResolveReference": true, + "userDefined": Object { + "MultipleNonResolvable": Object { + "federation": Object { + "hasResolveReference": false, + }, + "name": "MultipleNonResolvableResolvers", }, - "name": "MultipleResolvableResolvers", - }, - "Node": Object { - "federation": undefined, - "name": "NodeResolvers", - }, - "NotResolvable": Object { - "federation": Object { - "hasResolveReference": false, + "MultipleResolvable": Object { + "federation": Object { + "hasResolveReference": true, + }, + "name": "MultipleResolvableResolvers", }, - "name": "NotResolvableResolvers", - }, - "Query": Object { - "federation": Object { - "hasResolveReference": false, + "Node": Object { + "name": "NodeResolvers", }, - "name": "QueryResolvers", - }, - "Resolvable": Object { - "federation": Object { - "hasResolveReference": true, + "NotResolvable": Object { + "federation": Object { + "hasResolveReference": false, + }, + "name": "NotResolvableResolvers", }, - "name": "ResolvableResolvers", - }, - "User": Object { - "federation": Object { - "hasResolveReference": true, + "Query": Object { + "federation": Object { + "hasResolveReference": false, + }, + "name": "QueryResolvers", }, - "name": "UserResolvers", - }, - "UserError": Object { - "federation": Object { - "hasResolveReference": false, + "Resolvable": Object { + "federation": Object { + "hasResolveReference": true, + }, + "name": "ResolvableResolvers", }, - "name": "UserErrorResolvers", - }, - "UserOk": Object { - "federation": Object { - "hasResolveReference": false, + "User": Object { + "federation": Object { + "hasResolveReference": true, + }, + "name": "UserResolvers", + }, + "UserError": Object { + "federation": Object { + "hasResolveReference": false, + }, + "name": "UserErrorResolvers", + }, + "UserOk": Object { + "federation": Object { + "hasResolveReference": false, + }, + "name": "UserOkResolvers", + }, + "UserPayload": Object { + "name": "UserPayloadResolvers", }, - "name": "UserOkResolvers", - }, - "UserPayload": Object { - "federation": undefined, - "name": "UserPayloadResolvers", }, } `);