Which packages are impacted by your issue?
@graphql-codegen/typescript-rtk-query
Describe the bug
After updating @graphql-codegen/typescript-rtk-query from ^3.1.2 to ^4.0.1, the plugin hardcodes documentMode: DocumentMode.string in its visitor constructor. This generates documents wrapped in new TypedDocumentString(...) which is incompatible with RTK Query type expectations.
Type error:
Type 'TypedDocumentString' is not assignable to type 'string | DocumentNode'.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Use typescript-rtk-query plugin with near-operation-file preset
- Update @graphql-codegen/typescript-rtk-query to ^4.0.1
- Run codegen
- Run type checking
- See error: Type 'TypedDocumentString' is not assignable to type 'string | DocumentNode'
Expected behavior
The plugin should generate documents as plain gql strings (graphQLTag mode) or DocumentNode, compatible with RTK Query's type: { document: string | DocumentNode; ... }. The documentMode in codegen config should be respected instead of being hardcoded to DocumentMode.string.
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- NodeJS: [e.g. 18.5.0]
graphql version: [e.g. 16.3.0]
@graphql-codegen/* version(s): [e.g. 2.6.2]
Codegen Config File
generates:
src/:
preset: near-operation-file
plugins:
- typescript-operations
- typescript-rtk-query:
importBaseApiFrom: '@my/graphql-client'
exportHooks: true
config:
documentMode: graphQLTag # ignored by typescript-rtk-query v4
Additional context
In v4.0.1, RTKQueryVisitor constructor hardcodes:
documentMode: visitor_plugin_common_1.DocumentMode.string
This cannot be overridden via config. Workaround: downgrade to ^3.1.2.
Which packages are impacted by your issue?
@graphql-codegen/typescript-rtk-query
Describe the bug
After updating
@graphql-codegen/typescript-rtk-queryfrom^3.1.2to^4.0.1, the plugin hardcodesdocumentMode: DocumentMode.stringin its visitor constructor. This generates documents wrapped innew TypedDocumentString(...)which is incompatible with RTK Query type expectations.Type error:
Type 'TypedDocumentString' is not assignable to type 'string | DocumentNode'.
Your Example Website or App
Steps to Reproduce the Bug or Issue
Expected behavior
The plugin should generate documents as plain gql strings (graphQLTag mode) or DocumentNode, compatible with RTK Query's type:
{ document: string | DocumentNode; ... }. The documentMode in codegen config should be respected instead of being hardcoded to DocumentMode.string.Screenshots or Videos
No response
Platform
graphqlversion: [e.g. 16.3.0]@graphql-codegen/*version(s): [e.g. 2.6.2]Codegen Config File
generates:
src/:
preset: near-operation-file
plugins:
- typescript-operations
- typescript-rtk-query:
importBaseApiFrom: '@my/graphql-client'
exportHooks: true
config:
documentMode: graphQLTag # ignored by typescript-rtk-query v4
Additional context
In v4.0.1, RTKQueryVisitor constructor hardcodes:
documentMode: visitor_plugin_common_1.DocumentMode.string
This cannot be overridden via config. Workaround: downgrade to ^3.1.2.