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

near-operation-file + typescript-react-apollo = Failed to resolve .js import

Open tpinne opened this issue 3 years ago • 0 comments

Describe the bug

I still have the same issues as in #8065 even with emitLegacyCommonJSImports: false.

Your Example Website or App

Currently I have no simple repo to provide. If you can't get anywhere without let me know. I try to find time to provide a stripped down repo.

Steps to Reproduce the Bug or Issue

  1. Generate code using provided config
  2. Import into Next.js app
  3. Run dev server

Expected behavior

There should be no .js in the fragment filename.

Screenshots or Videos

No response

Platform

  • OS: macOS, Linux
  • NodeJS: 16.15.1, 16.17.0
  • graphql version: 16.6.0
  • @graphql-codegen/* version(s):
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
│  └─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
├─ @graphql-codegen/[email protected]
└─ @graphql-codegen/[email protected]

Codegen Config File

overwrite: true
schema: "src/graphql/Schema/*.graphqls"
documents: "src/graphql/**/*.graphql"
emitLegacyCommonJSImports: false
hooks:
  afterAllFileWrite:
    - prettier --write
config:
    avoidOptionals: true
    withComponent: false
    withHOC: false
    withHooks: true
    nonOptionalTypename: true
    preResolveTypes: true
    documentMode: documentNodeImportFragments
    pureMagicComment: true
    dedupeFragments: true
    scalars:
        Cursor: string
        Time: Date
generates:
    src/graphql/types.generated.ts:
        plugins:
            - add:
                  content: "/* eslint-disable */"
            - "typescript"
    src/utilities/Apollo/FragmentTypes.generated.ts:
        plugins:
            - add:
                  content: "/* eslint-disable */"
            - "fragment-matcher"
    src/utilities/Apollo/Helpers.generated.ts:
        plugins:
            - add:
                  content: "/* eslint-disable */"
            - "typescript-apollo-client-helpers"
    src/:
        preset: near-operation-file
        presetConfig:
            baseTypesPath: 'graphql/types.generated.ts'
            extension: .generated.tsx
        config:
          fetcher:
            endpoint: 'http://localhost/graphql'
        plugins:
            - add:
                  content: "/* eslint-disable */"
            - "typescript-operations"
            - add:
                  content: |
                      export type DummyTypeExport = Types.Exact<{ [key: string]: never }>;
            - "typescript-react-apollo"

Additional context

No response

tpinne avatar Sep 06 '22 08:09 tpinne