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

Using typescript-graphql-request with esm results in gql type error #228

Open
sirganya opened this issue Oct 24, 2022 · 1 comment
Open

Comments

@sirganya
Copy link

sirganya commented Oct 24, 2022

Describe the bug

When using graphql-codegen-esm and typescript-graphql-request

src/gql/generated/operations.ts:1489:34 - error TS2349: This expression is not callable. Type 'typeof import("me/node_modules/graphql-tag/lib/index")' has no call signatures.

Your Example Website or App

https://codesandbox.io/s/vigilant-framework-03nz6r?file=/codegen.yml

Steps to Reproduce the Bug or Issue

See the code sandbox example.

Expected behavior

I would expect gql types to be correct.

Screenshots or Videos

No response

Platform

macOs
NodeJs 17.9.1
"@graphql-cli/codegen": "^2.4.10",
"@graphql-codegen/cli": "^2.13.7",
"@graphql-codegen/typescript": "^2.7.4",
"@graphql-codegen/typescript-graphql-request": "^4.5.6",
"@graphql-codegen/typescript-operations": "^2.5.4",
"@graphql-codegen/typescript-resolvers": "^2.7.4",
"@types/node": "15.0.1",
"@types/rimraf": "^3",
"graphql": "^16.5.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"

Codegen Config File

overwrite: true
emitLegacyCommonJSImports: false
generates:
  ./src/gql/generated/schema.ts:
    schema:
      - ./src/gql/schema/*.ts:
          noPluck: true
    plugins:
      - typescript
      - typescript-resolvers
    config:
      makeResolverTypeCallable: true
      customResolverFn: ./codeGenCustomTypes#DefaultResolver
  ./src/gql/generated/operations.ts:
    schema:
      - ./src/gql/schema/*.ts:
          noPluck: true
    documents: ./src/gql/operations/*.graphql
    plugins:
      - typescript
      - typescript-operations
      - typescript-graphql-request
    config:
      typesPrefix: 'SDK_'

Additional context

I was wondering if changing the gqlImport config to use another lib might work. If that's the case do you have a recommended replacement

@dotansimha dotansimha transferred this issue from dotansimha/graphql-code-generator Feb 5, 2023
@joshuadutton
Copy link

I got around this issue by not using gql for my documents. Instead I use

    config: {
      documentMode: "documentNode",
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants