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

fix(typescript-graphql-request): Fix typescript error #549

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

pentla
Copy link
Contributor

@pentla pentla commented Dec 23, 2023

Description

In the latest version of @graphql-codegen/typescript-graphql-request, TypeScript error occured when moduleResolution is set to "nodenext" or "bundler".

In the issue #501 various version error reported.
I tried with the latest version.

    "@graphql-codegen/cli": "^5.0.0",
    "@graphql-codegen/typescript": "^4.0.1",
    "@graphql-codegen/typescript-graphql-request": "^6.1.0",
    "@graphql-codegen/typescript-operations": "^4.0.1",
    "graphql": "^16.8.1",
    "graphql-request": "^6.1.0",
    "typescript": "^5.3.3"

Here is my tsconfig.json. It is generated by tsc --init and I changed the module to "nodenext".

{
  "compilerOptions": {
    "target": "es2016",
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

Somehow, the type of graphql-requests cannot be imported by filename.
My solution was to import "GraphQLRequestHeader" from "graphql-request" instead of "graphql-request/build/cjs/types".

This solution was proposed in this comment.

In addition, I tried "graphql-request" version on 5.0.0, 5.1.0, 5.2.0, 6.0.0, 6.1.0, It works.

Related #501

This Issue is already closed, but now error reported is commented here, I created this PR.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Adding links to sandbox or providing screenshots can help us understand more about this PR and take
action on it as appropriate

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can
reproduce. Please also list any relevant details for your test configuration

  • Generated file to be no typescript error

I don't know how to generate using local plugin, I tried to console.log output in test code this file, checked TypeScript error.

Test Environment:

  • OS: MacOS 14.1.2
  • NodeJS: v20.9.0

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose
the solution you did and what alternatives you considered, etc...

Copy link

changeset-bot bot commented Dec 23, 2023

🦋 Changeset detected

Latest commit: dab0449

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/typescript-graphql-request Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pentla pentla changed the title Fix typescript error on graphql-request fix(typescript-graphql-request) Fix typescript error Dec 23, 2023
@pentla pentla changed the title fix(typescript-graphql-request) Fix typescript error fix(typescript-graphql-request): Fix typescript error Dec 23, 2023
@pentla
Copy link
Contributor Author

pentla commented Dec 25, 2023

@saihaj / @TkDodo Hello, Can you please review this PR?

@pentla
Copy link
Contributor Author

pentla commented Jan 18, 2024

@saihaj / @TkDodo Excuse me, Could you please take a look at the PR? If it would be better to contact someone else, could you let me know?

Copy link
Collaborator

@saihaj saihaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for detailed description and sorry for the delays

@saihaj saihaj merged commit ad8258c into dotansimha:main Feb 2, 2024
@github-actions github-actions bot mentioned this pull request Feb 2, 2024
@saihaj
Copy link
Collaborator

saihaj commented Feb 2, 2024

Released @graphql-codegen/typescript-graphql-request@6.2.0 🚀

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

Successfully merging this pull request may close these issues.

3 participants