Graphql-code-generator: Double // @flow comment added to generated file

Created on 15 Oct 2020  路  7Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

Hi, when I enable flow and flow-operations plugins at the same time, two // @flow headers are added to the graphql.js file.

To Reproduce
Steps to reproduce the behavior:

I tried to edit the template but it doesn't seem to work with the Flow plugins.

https://codesandbox.io/s/wizardly-paper-wsqgl?file=/document.graphql

  1. My GraphQL schema:
Not relevant for the issue
  1. My GraphQL operations:
Not relevant for the issue
  1. My codegen.yml config file:
overwrite: true
schema: 'allSchema.graphql'
generates:
  ./src/generated/graphql.js:
    documents: 'queries/*.js'
    plugins:
      - flow
      - flow-operations

Expected behavior

Environment:

  • OS: macOS Catalina
  • @graphql-codegen/flow: same as codesandbox
  • @graphql-codegen/flow-operations: same as codesandbox
  • NodeJS: 14.5.0

Additional context

bug plugins waiting-for-release

Most helpful comment

Fixed in @graphql-codegen/[email protected].

All 7 comments

I think this was introduced in: https://github.com/dotansimha/graphql-code-generator/pull/4609
Does it's breaking anything @FezVrasta ? or it's just semantics?

It errors in my create-react-app project

@FezVrasta build error or lint error? As far as I can tell, the Flow compiler works perfectly fine with that...

image

When the double comment is present, I also get a bunch of other errors on any file that imports from it, because it doesn't recognize the types.

Cannot use CreateAddendumMutationVariables as a type. A name can be used as a type only if it refers to a type,
interface, class, or enum definition. To get the type of a non-class value, use typeof. [value-as-type]

Having the the same issue. This is where flow throws:

| MultipleFlowAttributes ->
  [
    text "Unexpected ";
    code "@flow";
    text " declaration. Only one per ";
    text "file is allowed.";
  ]

What if we remove // @flow prepend from flow operations since flow plugin already has it?

Fixed in @graphql-codegen/[email protected].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steebchen picture steebchen  路  3Comments

leonardfactory picture leonardfactory  路  3Comments

fvisticot picture fvisticot  路  3Comments

SimenB picture SimenB  路  3Comments

iamdanthedev picture iamdanthedev  路  3Comments