Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@graphql-codegen/cli 3.2.0 watch mode regeneration triggers on all file changes (not just files specified in config documents pattern) #9045

Closed
GrantASL19 opened this issue Feb 23, 2023 · 3 comments · Fixed by #9051
Assignees
Labels
kind/bug Bug :-( stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested

Comments

@GrantASL19
Copy link

GrantASL19 commented Feb 23, 2023

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

In @graphql-codegen/cli 3.2.0 watch mode regeneration is triggered by editing any file in the project. In <=3.1.0 regeneration only triggers when a file in the config’s documents pattern is edited (correct me if I’m wrong!).

In our projects this is triggering many regenerations, e.g. seemingly as files are written into the Next.js build folder.

This seems to be a result of #9009

Please let me know if I’m missing something! I tried passing a pattern as the --watch argument or watch config but it seems to make no difference. But IMO even if there’s a configuration workaround this was an unexpected breaking change in a minor release.

Your Example Website or App

https://github.com/GrantASL19/graphql-codegen-cli-watch-regression-repro

Steps to Reproduce the Bug or Issue

  • npm i
  • npm run generate-graphql-watch
  • Edit src/test.js and src/graphQl/staticPage.graphql and note that the following is output when either file changes:
    ✔ Parse Configuration
    ✔ Generate outputs
    ℹ Watching for changes...
    
  • Stop the watch with Ctrl-C
  • npm i @graphql-codegen/[email protected]
  • npm run generate-graphql-watch
  • Edit src/test.js and src/graphQl/staticPage.graphql and note that the regeneration is only triggered when src/graphQl/staticPage.graphql changes.

Expected behavior

Regeneration should only trigger when I change a file specified in the config documents field.

Screenshots or Videos

No response

Platform

  • OS: macOS 13.2.1
  • NodeJS: 19.6.1
  • @graphql-codegen/cli version 3.2.0

Codegen Config File

/** @type {import('graphql-config').IGraphQLConfig} */
const graphQlConfig = {
  documents: "./src/graphQl/**/*.graphql",
  extensions: {
    /** @type {import("@graphql-codegen/cli").CodegenConfig} */
    codegen: {
      generates: { 
        "./src/generated/graphQl.ts": {
          overwrite: true,
          plugins: [
            "typescript",
            "typescript-operations",
            "typescript-graphql-request",
          ],
          config: {
            avoidOptionals: {
              field: true,
              inputValue: false,
              object: false,
              defaultValue: false,
            },
            dedupeFragments: true,
            documentMode: "string",
            enumsAsTypes: true,
            inlineFragmentTypes: "combine",
            typesPrefix: "Gql",
            omitOperationSuffix: true,
            onlyOperationTypes: true,
            preResolveTypes: true,
            scalars: {
              Date: "string",
              DateTime: "string",
              FlatTags: "../types/apiTypes#FlatTags",
              RichTextFieldType: "string",
            },
            skipTypename: true,
          },
        },
      },
    },
  },
  schema: "src/schema.graphql",
};

module.exports = graphQlConfig;

Additional context

No response

@saihaj saihaj self-assigned this Feb 23, 2023
@saihaj saihaj added kind/bug Bug :-( stage/1-reproduction A reproduction exists labels Feb 23, 2023
@saihaj saihaj added stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested and removed stage/1-reproduction A reproduction exists labels Feb 23, 2023
@saihaj
Copy link
Collaborator

saihaj commented Feb 23, 2023

Thanks for reporting this! I have created a fix here #9051

@saihaj
Copy link
Collaborator

saihaj commented Feb 23, 2023

@GrantASL19
Copy link
Author

Amazing, thanks for the quick fix and release Saihajpreet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug :-( stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants