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

typescript-generic-sdk unused generic paramter

Open JanStevens opened this issue 3 years ago • 2 comments

Describe the bug

When generating a generic SDK (without raw requests) an unused generic param is introduced. This causes typescript errors when noUnusedParameters is set to true.

The bug was introduced in https://github.com/dotansimha/graphql-code-generator/pull/7689, ideally in https://github.com/dotansimha/graphql-code-generator/pull/7689/files#diff-c0735fcd78dffef10d637a4d56bc3d1e70efa65258aa96533d0fcced83254e75R98 a check should be added that if we are not generating a raw request the additional E generic should be dropped

Your Example Website or App

https://codesandbox.io/s/nameless-sky-t833oi?file=/types.ts

Steps to Reproduce the Bug or Issue

  1. Use latest version of typescript-generic-sdk
  2. When generating the sdk the Requester type had an unused generic param

Expected behavior

I expect that the generated sdk does not contain unused params

Screenshots or Videos

Screenshot 2022-08-03 at 08 31 21

Platform

  • OS: macOs
  • NodeJS: 16
  • graphql version: 16.5.0
  • @graphql-codegen/* version(s):
    • "@graphql-codegen/add": "3.2.0",
    • "@graphql-codegen/cli": "^2.4.0",
    • "@graphql-codegen/typescript": "2.7.2",
    • "@graphql-codegen/typescript-operations": "2.5.2",
    • "@graphql-codegen/typescript-generic-sdk": "2.5.0",
    • "graphql": "16.5.0",
    • "typescript": "4.7.4"

Codegen Config File

schema: schema.graphql
documents: document.graphql
generates:
  types.ts:
    config:
      avoidOptionals:
        field: true
      documentMode: string
      pureMagicComment: true
      dedupeFragments: true
    plugins:
      - typescript
      - typescript-operations
      - typescript-generic-sdk

Additional context

No response

JanStevens avatar Aug 03 '22 06:08 JanStevens

@dotansimha @ardatan Sorry to tag you guys, but I'm having the same problem as well, any ideas what's happening?! I just updated the package and I'm encountering this issue, I don't know what the E type parameter is even about :/

aradalvand avatar Aug 18 '22 16:08 aradalvand

Hey ! I just wrote a PR addressing this issue. Hope it can speed up the resolution 💪

Thanks for pointing out this issue 🙇

https://github.com/dotansimha/graphql-code-generator/pull/8313

heiso avatar Sep 02 '22 07:09 heiso