urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.54k stars 444 forks source link

patch: Mark `@urql/core` as a peer as well as a regular dependency #3579

Closed kitten closed 2 months ago

kitten commented 2 months ago

Context

Originally (I reckon during the introduction of @urql/core), we decided to only include @urql/core as a dependency, since it never is a direct dependency. This allowed it to install automatically and deduplicate as long as all ranges match.

This wasn't ever a problem assuming deduplication was working (which it sometimes isn't in Yarn Legacy). However, @urql/core is only actively instantiated once in any given app. This means that for all exchanges it's only used to share types.

Problems with this is though, @urql/core's types contain instances that TypeScript will always consider as incompatible if they're duplicated. This means that this approach stopped working for TypeScript.

Summary

While we could provide shared global namespace types in @urql/core, which is my alternative proposal to solve this, we can also mark all dependencies on @urql/core as peer dependencies now.

Generally, peer dependencies install automatically with all package managers these days. But to keep backwards compatibility we can also keep @urql/core in dependencies at the same time. This should simply prompt package managers to always deduplicate it.

This PR also removes the >= range on it (although it's perfectly safe, this allows us to revamp some APIs in the next major of @urql/core), and updates the graphql peer dependency

Set of changes

changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: 8cbd957baa731d13cd46b7193487bdce3eee315d

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

This PR includes changesets to release 14 packages | Name | Type | | ----------------------------- | ----- | | @urql/exchange-request-policy | Minor | | @urql/introspection | Minor | | @urql/exchange-graphcache | Minor | | @urql/preact | Minor | | @urql/svelte | Minor | | @urql/exchange-persisted | Minor | | urql | Minor | | @urql/exchange-populate | Minor | | @urql/exchange-context | Minor | | @urql/exchange-execute | Minor | | @urql/exchange-refocus | Minor | | @urql/vue | Minor | | @urql/exchange-retry | Minor | | @urql/exchange-auth | 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