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

Watch mode exits after first run when using near-operation-file #2069

Closed
mvestergaard opened this issue Jun 27, 2019 · 4 comments
Closed

Watch mode exits after first run when using near-operation-file #2069

mvestergaard opened this issue Jun 27, 2019 · 4 comments
Labels
core Related to codegen core/cli waiting-for-release Fixed/resolved, and waiting for the next stable release

Comments

@mvestergaard
Copy link
Contributor

Describe the bug

When using the near-operation-file preset watch mode exits right after the first iteration.

To Reproduce
Steps to reproduce the behavior:
Run gql-gen with near-operation-file configured

  1. My GraphQL schema:
# Schema is huge. If you can't reproduce, I'll try to find the minimal reproduction setup
  1. My GraphQL operations:
# Same as above
  1. My codegen.yml config file:
schema: ./packages/app/src/graphql/schema/schema.graphql
overwrite: true
documents:
  - ./packages/app/src/**/*.fragment.ts
  - ./packages/app/src/**/*.query.ts
  - ./packages/app/src/**/*.mutation.ts
generates:
  ./packages/app/src/graphql/schema/index.ts:
    plugins:
      - add: '/* eslint-disable */'
      - typescript
    config:
      scalars:
        Date: Date
        DateTime: Date
        DateTimeOffset: Date
        Guid: string
        Decimal: number
        Seconds: number
        Milliseconds: number
  ./packages/app/src/graphql/schema/introspection.ts:
    plugins:
      - add: '/* eslint-disable */'
      - fragment-matcher
  ./packages/app/src:
    preset: near-operation-file
    presetConfig:
      extension: .generated.tsx
      baseTypesPath: graphql/schema
    plugins:
      - add: '/* eslint-disable */'
      - typescript-operations
      - typescript-react-apollo
    config:
      withHOC: false
      withComponent: false
      withHooks: true

Expected behavior

Watch mode should keep running

Environment:

  • OS: Windows 10
  • @graphql-codegen/1.3.1:
  • NodeJS: 12.3.1

Additional context

image

Other issues with near-operation-file

  • Output is quite spammy. As also seen above. Each generated file produces a √ Parse configuration line
  • While running, a weird warning appears (i think it comes from prettier, see screenshot below)
  • Execution is quite slow compared to generating a single file. At least 300% slower.
  • When referencing fragments, alot of unused imports are added to the generated files (i think this has been reported already)

image

@mvestergaard
Copy link
Contributor Author

The weird prettier error should be fixed by #2071

@dotansimha dotansimha added bug core Related to codegen core/cli waiting-for-release Fixed/resolved, and waiting for the next stable release labels Jul 3, 2019
@mvestergaard
Copy link
Contributor Author

@dotansimha I think most of this is resolved, but are you still working out some kinks with near-operation-file? I noticed an issue where the base types file isn't always referenced in mutations and queries, when it should.
If you're not aware of that issue, I can create a new issue for it, and try to provide some minimal reproduction steps.

@mvestergaard
Copy link
Contributor Author

The issue I'm seeing somehow relates to this bit of code: https://github.com/dotansimha/graphql-code-generator/blob/master/packages/presets/near-operation-file/src/index.ts#L161
I'm wondering whether it may not be easier to just always reference the base types file, and not try to be smart about it. Are there ever cases where a file doesn't need it?

@dotansimha
Copy link
Owner

Fixed in 1.4.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli waiting-for-release Fixed/resolved, and waiting for the next stable release
Projects
None yet
Development

No branches or pull requests

2 participants