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

graphql-request: support emitLegacyCommonJSImports: false #8334

Conversation

jcarrus
Copy link
Contributor

@jcarrus jcarrus commented Sep 7, 2022

Description

This PR fixes a bug where the graphql-request plugin would not add a .js extension the graphql-request/dist/types.dom path in the generated SDK when using emitLegacyCommonJSImports: false. This would cause Typescript to error when using the module: nodenext compiler option.

path/to/generated-file.ts:2:22 - error TS2307: Cannot find module 'graphql-request/dist/types.dom' or its corresponding type declarations.

2 import * as Dom from 'graphql-request/dist/types.dom';
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Related #8022 (issue) and #8235 (stale PR)

Type of change

  • 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):

None

How Has This Been Tested?

I've tested on a local project and can attest that Typescript with module: nodenext compiles code generated by this branch, but does not successfully compile code without these changes.

Otherwise the tests provide coverage for this change.

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

This PR extends #8235 by:

  • rebasing on master
  • updating the failing tests
  • adding a new test

@changeset-bot
Copy link

changeset-bot bot commented Sep 7, 2022

🦋 Changeset detected

Latest commit: bc9f095

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 Patch

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

@jcarrus jcarrus force-pushed the jcarrus.fix-missing-extension-for-graphql-request branch from bb56baa to bc9f095 Compare September 7, 2022 19:02
Copy link
Contributor

@charlypoly charlypoly left a comment

Choose a reason for hiding this comment

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

Thank you for pushing it forward @jcarrus! ⚡

@charlypoly charlypoly merged commit e6e497a into dotansimha:master Sep 20, 2022
@charlypoly
Copy link
Contributor

Released as part of @graphql-codegen/[email protected] 📦

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.

2 participants