croutonn/graphql-codegen-plugin-typescript-swr

Duplicated keys with autogenSWRKey enabled

vitorcamachoo opened this issue · 0 comments

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    At our company, we're working with multiple GraphQL services, and it can happen to have queries with the same identifier, which result on duplicated key generation for hooks. Example:

generates:
  # Api codegen
  libs/backoffice/api/graphql/yacooba/request.ts:
    documents:
      - 'apps/**/*.yacooba.graphql'
      - 'libs/**/*.yacooba.graphql'
    plugins:
      - typescript
      - typescript-operations
      - typescript-graphql-request
      - plugin-typescript-swr
    config:
      autogenSWRKey: true
      skipTypename: true

 libs/backoffice/api/graphql/protocol/request.ts:
    documents:
      - 'apps/**/*.protocol.graphql'
      - 'libs/**/*.protocol.graphql'
    plugins:
      - typescript
      - typescript-operations
      - typescript-graphql-request
      - plugin-typescript-swr
    config:
      autogenSWRKey: true
      skipTypename: true

The two apis have two queries with the same name, (events), resulting on the generation of two hooks with the same key:

Api 1:
Screenshot 2021-03-17 at 16 48 19

Api 2:
Screenshot 2021-03-17 at 16 48 51

Is there any way to avoid this, maintaining the configuration autogenSWRKey active ?