Skip to content

Commit

Permalink
Ensure no federation: undefined case
Browse files Browse the repository at this point in the history
  • Loading branch information
eddeee888 committed Aug 22, 2024
1 parent 06035ca commit 3034c9a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
`);
Expand Down

0 comments on commit 3034c9a

Please sign in to comment.