graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

typescript-operations does not support declarationKind

Open benasher44 opened this issue 3 years ago • 2 comments

Which packages are impacted by your issue?

@graphql-codegen/typescript-operations

Describe the bug

Set declarationKind: 'interface', and types generated by the typescript plugin switch to using interface, but typescript-operation types still use type, despite typescript-operations documenting that declarationKind is a supported option.

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

  1. Setup a project that uses typescript and typescript-operations
  2. Set declarationKind to interface

Expected behavior

typescript-operation types switch to using interface

Screenshots or Videos

No response

Platform

  • OS: macOS 13
  • NodeJS: 18
  • graphql: 16
  • @graphql-codegen/* @graphql-codegen/typescript-operations: 2.5.7

Codegen Config File

schema: "../backend/src/graphql_server//*.graphql" documents: "./src/graphql//*.graphql" extensions: codegen: overwrite: true config: dedupeFragments: true noNamespaces: true strict: true scalars: Date: string DateTime: string useExplicitTyping: true declarationKind: "interface" generates: src/generated/graphql/graphql.tsx: plugins: - "typescript" - "typescript-operations" - "fragment-matcher" - "typed-document-node"

Additional context

No response

benasher44 avatar Dec 01 '22 15:12 benasher44

At the very least the documentation should be updated to reflect this reality - I spent a fair amount of time trying to make it work. https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-operations#declarationkind

TomSwift avatar Jan 18 '23 17:01 TomSwift

Still an issue, wasted a lot of time trying to get this to work before finding this issue.

ryanb93 avatar Apr 25 '24 12:04 ryanb93

We also need this. Its not very useful if you cant map it on an OO model without having to maintain the whole model your self.

Harriebo avatar Nov 04 '25 16:11 Harriebo

Hi all 👋

Major version changes are under work: https://github.com/dotansimha/graphql-code-generator/pull/10496 This will most likely be included in that. Will keep this issue updated with news

eddeee888 avatar Nov 15 '25 00:11 eddeee888