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

typescript-msw: Correct compatibility with msw@^2 #594

Merged
merged 1 commit into from
Feb 2, 2024
Merged

typescript-msw: Correct compatibility with msw@^2 #594

merged 1 commit into from
Feb 2, 2024

Conversation

lachieh
Copy link
Contributor

@lachieh lachieh commented Jan 30, 2024

Description

The @graphql-codegen/typescript-msw plugin is not fully compatible with msw@^2.0.0.

Related #563, #468

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

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

  • Updated unit tests
  • Tested against my organization's codebase using linked package

Test Environment:

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

Previously, #468 was closed via #484 by resolving the types using the Parameters<...> type. While
this kept backwards compatibility for msw@^1, it doesn't fully work with msw@^2. Specifically,
in msw@^1, the resolver callback was passed a Response object which could be invoked with the
res.once() method while in msw@^2, the response must be a native HttpReponse object and the
once method is now replaced by the once property on a second options parameter.

This PR adds the second options parameter to the resolver callback and updates the types to be
compatible with msw@^2. This is a breaking change for msw@^1 users. If it is desirable, I can
add a new plugin option to allow users to choose between the two major versions of msw.

Copy link

changeset-bot bot commented Jan 30, 2024

🦋 Changeset detected

Latest commit: 0734371

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-msw Major

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

@lachieh lachieh changed the title typescript-msw: Switch compatibility with msw@^2 * Add peerDependency for msw@^2.0.0 * BREAKING: Replace Parameters<typeof> with types from msw@^2.0.0 * BREAKING: Use generated DocumentNodes instead of operation name string for query/mutation parameters typescript-msw: Switch compatibility with msw@^2 Jan 30, 2024
@lachieh lachieh changed the title typescript-msw: Switch compatibility with msw@^2 typescript-msw: Correct compatibility with msw@^2 Jan 30, 2024
* Add peerDependency for msw@^2.0.0

* BREAKING: Replace `Parameters<typeof>` with types from msw@^2.0.0

Signed-off-by: Lachlan Heywood <lachieh@users.noreply.github.com>
@saihaj
Copy link
Collaborator

saihaj commented Feb 2, 2024

thank you!

@saihaj saihaj merged commit 40f3676 into dotansimha:main Feb 2, 2024
14 checks passed
@github-actions github-actions bot mentioned this pull request Feb 2, 2024
@lachieh
Copy link
Contributor Author

lachieh commented Feb 2, 2024

@saihaj no problems! Where does the documentation live? I can update that also for when the release goes out.

@saihaj
Copy link
Collaborator

saihaj commented Feb 2, 2024

Package published @graphql-codegen/typescript-msw@3.0.0

Docs live in main repo -> https://github.com/dotansimha/graphql-code-generator/tree/master/website

@lachieh
Copy link
Contributor Author

lachieh commented Feb 2, 2024

Thank you! Updating the docs now

@lachieh
Copy link
Contributor Author

lachieh commented Feb 5, 2024

@saihaj docs are updated in: dotansimha/graphql-code-generator#9834

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