Graphql-code-generator: Watch mode do not update output with JavaScript export schema type

Created on 27 Feb 2020  路  6Comments  路  Source: dotansimha/graphql-code-generator

I have the same issue as @grezxune mentioned in here: https://github.com/dotansimha/graphql-code-generator/issues/1609#issuecomment-554584784

Watching files works, but output is untouched on change

with this config

schema: src/graph/schema.ts
require:
    - ts-node/register
watch:
    - src/graph/nodes/**/*.ts
overwrite: true
generates:
    src/graph/gen-types.ts:
        plugins:
            - typescript

btw: I didn't find any docs about the wildcard-path passed to watch argument.

bug core waiting-for-release

Most helpful comment

Fixed. You can use the alpha 1.13.6-alpha-1ace8c2f.44 for now.

@melounek thank you for the reproduction, it really helped!

All 6 comments

I have the same issue with typescript, it does not refresh the generated type unless I restart codegen or edit my config file (codegen.yml).

overwrite: true
schema: "http://localhost:4000"
documents: null
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-resolvers"
  ./graphql.schema.json:
    plugins:
      - "introspection"

@melounek @debrice can you please share a reproduction in a repo/codesandbox?

There is repro-repo: https://github.com/melounek/repro-codegen (with readme how to reproduce)
thanks @dotansimha

Thanks @melounek !
I can confirm that this is caused by require.cache. I think watch: feature should handle that manually and clear the items from the cache, because otherwise we'll get the same file even if it has changed.

I'm working on a fix here: https://github.com/dotansimha/graphql-code-generator/pull/4037

Fixed. You can use the alpha 1.13.6-alpha-1ace8c2f.44 for now.

@melounek thank you for the reproduction, it really helped!

Fixed in v1.14.0.

Was this page helpful?
0 / 5 - 0 ratings