graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

emitLegacyCommonJSImports doesn't work with fragment imports

Open chrisands opened this issue 3 years ago • 0 comments
trafficstars

Describe the bug

After https://github.com/dotansimha/graphql-code-generator/pull/8077 generation always emits .js extension. Reproducable only in [email protected], in 2.3.1 everything ok.

Your Example Website or App

Steps to Reproduce the Bug or Issue

  1. Generate using near-file-operations preset and emitLegacyCommonJSImports: true option.
  2. Get import with .js extension
  3. Get error because you use typescript-operations

Expected behavior

I expect to generate without .js extension on atleast with .ts extension.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 16.9.1
  • graphql version: 16.3.0
  • @graphql-codegen/* version(s): [e.g. 2.6.2]

Codegen Config File

schema: ${SCHEMA_URL}
documents: 'src/server/**/*.graphql'
hooks:
  afterAllFileWrite:
    - eslint --fix
    - prettier --write
generates:
  ./src/server/graphqlSchema.ts:
    config:
    plugins:
      - add: &scheme-add
          content:
            - '/**'
            - ' * @generated This file was automatically generated and should not be edited.'
            - ' */'
      - typescript

  ./src/server/:
    preset: near-operation-file
    presetConfig:
      extension: .ts
      baseTypesPath: graphqlSchema.ts
      importTypesNamespace: BFF
      folder: __generated__
    config:
      gqlImport: graphql-tag#gql
      nonOptionalTypename: true
      addTypenameToSelectionSets: true
      emitLegacyCommonJSImports: true
    plugins:
      - add: &operations-add
          content:
            - '/**'
            - ' * @generated This file was automatically generated and should not be edited.'
            - ' */'
            - '/* eslint-disable @typescript-eslint/no-unused-vars */'
      - typescript-operations
      - typed-document-node

Additional context

No response

chrisands avatar Aug 04 '22 15:08 chrisands