dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.86k stars 1.33k forks source link

pluckConfig option doesn't work #7363

Closed lucashfreitas closed 2 years ago

lucashfreitas commented 2 years ago

Describe the bug

Hello, I am trying to use pluckConfig to remove gql from graphl-tag and use my custom ggl tag module but the pluck config doesn't seems to be working.

I have added the config in the root codegen.yml file as stated in the docs https://www.graphql-code-generator.com/docs/config-reference/codegen-config.

The generated file is still importing the gql from graphql-tag.

To Reproduce

I have created a minimal repository that reproduces the issue. It's available here https://github.com/lucashfreitas/graphql-codegen-pluckConfigIssue. Note that despite we have pluckConfig modules set in codegen the generated graphql is still importing the gq; from graphql-tag.

  1. Download the repo availabel at https://github.com/lucashfreitas/graphql-codegen-pluckConfigIssue
  2. Run npm install or yarn to install the depencies.
  3. Run yarn codegen and note that the graphql generated will import the gql from graphql-tag despite the pluckConfig is set to a different module.

Environment:

ardatan commented 2 years ago

pluckConfig should be used to define how to extract GraphQL related code from TS and JS files. It is not for gql imports in the generated files; You can configure the package gql tag should be imported from by using gqlImport as shown here; https://www.graphql-code-generator.com/plugins/typescript-graphql-request

lucashfreitas commented 2 years ago

Thanks @ardatan !