Which packages are impacted by your issue?
@graphql-codegen/typescript-resolvers
Describe the bug
When using typesPrefix: "I" (or any prefix) with federation: true, the generated
FederationReferenceTypes type references FederationTypes without the configured prefix,
causing a TypeScript compilation error.
The generated code defines IFederationTypes (with prefix) but references it as
FederationTypes (without prefix) inside IFederationReferenceTypes.
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
codegen.yml:
schema: src/api/graphql/schema.graphql
generates:
src/api/graphql/types.ts:
plugins:
- typescript
- typescript-resolvers
config:
typesPrefix: I
federation: true
schema.graphql (minimal example with federation):
type Query {
_service: _Service!
}
type _Service {
sdl: String
}
type Channel @key(fields: "id") {
id: ID!
}
Run codegen and compile with TypeScript.
Actual behavior:
The generated code uses FederationTypes (without prefix) in the reference:
export type IFederationTypes = ResolversObject<{
Channel: IChannel;
}>;
export type IFederationReferenceTypes = ResolversObject<{
Channel:
( { __typename: 'Channel' }
& GraphQLRecursivePick<FederationTypes['Channel'], {"id":true}> ); // ❌ Missing "I" prefix
}>;
TypeScript error:
error TS2552: Cannot find name 'FederationTypes'. Did you mean 'IFederationTypes'?
Expected behavior
The generated code should use IFederationTypes consistently:
export type IFederationTypes = ResolversObject<{
Channel: IChannel;
}>;
export type IFederationReferenceTypes = ResolversObject<{
Channel:
( { __typename: 'Channel' }
& GraphQLRecursivePick<IFederationTypes['Channel'], {"id":true}> );
}>;
Screenshots or Videos
No response
Platform
OS: macOS / Linux
@graphql-codegen/cli: 6.1.1
@graphql-codegen/typescript-resolvers: 5.0.0 - 5.1.5 (all 5.x versions affected)
Node.js: 20.x / 22.x
Codegen Config File
schema: src/api/graphql/schema.graphql
generates:
src/api/graphql/types.ts:
plugins:
- typescript
- typescript-resolvers
config:
typesPrefix: I
federation: true
Additional context
Versions tested
| vers. | Bug present |
| 4.5.2 | ❌ No (no FederationTypes generated) |
| 5.0.0 | ✅ Yes |
| 5.0.1 | ✅ Yes |
| 5.1.0 | ✅ Yes |
| 5.1.3 | ✅ Yes |
| 5.1.4 | ✅ Yes |
| 5.1.5 | ✅ Yes |
Potential fix location
The bug appears to be in packages/plugins/typescript/resolvers/src/visitor.ts.
In the buildFederationReferenceTypes() method, the type declaration name correctly uses
this.convertName('FederationReferenceTypes'), but the referenceSelectionSetsString
contains a hardcoded reference to FederationTypes:
& GraphQLRecursivePick<FederationTypes['Channel'], {"id":true}>
The fix should apply this.convertName('FederationTypes') when building
referenceSelectionSetsString, so it becomes:
& GraphQLRecursivePick<IFederationTypes['Channel'], {"id":true}>
The issue is likely in the code that constructs referenceSelectionSetsString - it should
use the naming convention when referencing FederationTypes.
Workaround
Pin @graphql-codegen/typescript-resolvers to ^4.5.2 until this is fixed.
Which packages are impacted by your issue?
@graphql-codegen/typescript-resolvers
Describe the bug
When using typesPrefix: "I" (or any prefix) with federation: true, the generated
FederationReferenceTypes type references FederationTypes without the configured prefix,
causing a TypeScript compilation error.
The generated code defines IFederationTypes (with prefix) but references it as
FederationTypes (without prefix) inside IFederationReferenceTypes.
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
schema.graphql (minimal example with federation):
Run codegen and compile with TypeScript.
Actual behavior:
The generated code uses FederationTypes (without prefix) in the reference:
TypeScript error:
error TS2552: Cannot find name 'FederationTypes'. Did you mean 'IFederationTypes'?
Expected behavior
The generated code should use IFederationTypes consistently:
Screenshots or Videos
No response
Platform
OS: macOS / Linux
@graphql-codegen/cli: 6.1.1
@graphql-codegen/typescript-resolvers: 5.0.0 - 5.1.5 (all 5.x versions affected)
Node.js: 20.x / 22.x
Codegen Config File
Additional context
Versions tested
| vers. | Bug present |
| 4.5.2 | ❌ No (no FederationTypes generated) |
| 5.0.0 | ✅ Yes |
| 5.0.1 | ✅ Yes |
| 5.1.0 | ✅ Yes |
| 5.1.3 | ✅ Yes |
| 5.1.4 | ✅ Yes |
| 5.1.5 | ✅ Yes |
Potential fix location
The bug appears to be in packages/plugins/typescript/resolvers/src/visitor.ts.
In the buildFederationReferenceTypes() method, the type declaration name correctly uses
this.convertName('FederationReferenceTypes'), but the referenceSelectionSetsString
contains a hardcoded reference to FederationTypes:
The fix should apply this.convertName('FederationTypes') when building
referenceSelectionSetsString, so it becomes:
The issue is likely in the code that constructs referenceSelectionSetsString - it should
use the naming convention when referencing FederationTypes.
Workaround
Pin @graphql-codegen/typescript-resolvers to ^4.5.2 until this is fixed.