Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@urql/svelte

urql-graphql43.1kMIT4.2.3TypeScript support: included

A highly customizable and versatile GraphQL client for Svelte

graphql client, state management, cache, graphql, exchanges, svelte

readme

urql

A highly customisable and versatile GraphQL client

CI Status Weekly downloads Discord

✨ Features

urql is a GraphQL client that exposes a set of helpers for several frameworks. It's built to be highly customisable and versatile so you can take it from getting started with your first GraphQL project all the way to building complex apps and experimenting with GraphQL clients.

📃 For more information, check out the docs.

💙 Sponsors

BigCommerce
BigCommerce
WunderGraph
WunderGraph
The Guild
The Guild
BeatGig
BeatGig

🙌 Contributing

The urql project was founded by Formidable and is actively developed by the urql GraphQL team.

If you'd like to get involved, check out our Contributor's guide.

📦 Releases

All new releases and updates are listed on GitHub with full changelogs. Each package in this repository further contains an independent CHANGELOG.md file with the historical changelog, for instance, here’s @urql/core’s changelog.

If you’re upgrading to v4, check out our migration guide, posted as an issue.

New releases are prepared using changesets, which are changelog entries added to each PR, and we have “Version Packages” PRs that once merged will release new versions of urql packages. You can use @canary releases from npm if you’d like to get a preview of the merged changes.

📃 Documentation

The documentation contains everything you need to know about urql, and contains several sections in order of importance when you first get started:

Furthermore, all APIs and packages are self-documented using TSDocs. If you’re using a language server for TypeScript, the documentation for each API should pop up in your editor when hovering urql’s code and APIs.

You can find the raw markdown files inside this repository's docs folder.

changelog

@urql/svelte

4.2.3

Patch Changes

4.2.2

Patch Changes

  • Add type for hasNext to the query and mutation results Submitted by @JoviDeCroock (See #3703)

4.2.1

Patch Changes

  • add support for Svelte 5 in the peerDependencies Submitted by @itssumitrai (See #3634)

4.2.0

Minor Changes

  • Mark @urql/core as a peer dependency as well as a regular dependency Submitted by @kitten (See #3579)

Patch Changes

  • ⚠️ Fix subscription handlers to not receive null values Submitted by @kitten (See #3581)

4.1.1

Patch Changes

4.1.0

Minor Changes

Patch Changes

4.0.4

Patch Changes

  • ⚠️ Fix queryStore and subscriptionStore not subscribing when writable calls its StartStopNotifier. This caused both stores to be inactive and become unresponsive when they’ve been unsubscribed from once, as they wouldn’t be able to restart their subscriptions to the Client Submitted by @kitten (See #3331)

4.0.3

Patch Changes

  • Updated peer dependency range to include support for Svelte ^4.0.0 Submitted by @ategen3rt (See #3302)

4.0.2

Patch Changes

  • Update build process to generate correct source maps Submitted by @kitten (See #3201)

4.0.1

Patch Changes

  • Publish with npm provenance Submitted by @kitten (See #3180)

4.0.0

Major Changes

  • Update OperationResult.hasNext and OperationResult.stale to be required fields. If you have a custom exchange creating results, you'll have to add these fields or use the makeResult, mergeResultPatch, or makeErrorResult helpers Submitted by @kitten (See #3061)
  • Move handler, which combines subscription events, from mutationStore to subscriptionStore. It’s accidentally been defined and implemented on the wrong store and was meant to be on subscriptionStore Submitted by @kitten (See #3078)

Minor Changes

  • Allow mutations to update their results in bindings when hasNext: true is set, which indicates deferred or streamed results Submitted by @kitten (See #3103)

Patch Changes

3.0.4

Patch Changes

  • ⚠️ Fix type utilities turning the variables properties optional when a type from TypedDocumentNode has no Variables or all optional Variables. Previously this would break for wrappers, e.g. in code generators, or when the type didn't quite match what we'd expect Submitted by @kitten (See #3022)
  • Updated dependencies (See #3007, #2962, #3007, #3015, and #3022)

3.0.3

Patch Changes

3.0.2

Patch Changes

  • Move remaining Variables generics over from object default to Variables extends AnyVariables = AnyVariables. This has been introduced previously in #2607 but some missing ports have been missed due to TypeScript not catching them previously. Depending on your TypeScript version the object default is incompatible with AnyVariables, by @kitten (See #2843)
  • Updated dependencies (See #2843, #2847, #2850, and #2846)

3.0.1

Patch Changes

  • Tweak the variables type for when generics only contain nullable keys, by @JoviDeCroock (See #2623)

3.0.0

Major Changes

  • Goodbye IE11! 👋 This major release removes support for IE11. All code that is shipped will be transpiled much less and will not be ES5-compatible anymore, by @kitten (See #2504)
  • Implement stricter variables types, which require variables to always be passed and match TypeScript types when the generic is set or inferred. This is a breaking change for TypeScript users potentially, unless all types are adhered to, by @kitten (See #2607)
  • Upgrade to Wonka v6 (wonka@^6.0.0), which has no breaking changes but is built to target ES2015 and comes with other minor improvements. The library has fully been migrated to TypeScript which will hopefully help with making contributions easier!, by @kitten (See #2504)

Patch Changes

2.0.2

Patch Changes

  • Made variables optional for all operations, by @mpiorowski (See #2496)
  • ⚠️ Fix issue with subscriptionStore and queryStore eagerly terminating the subscription due to derived, by @JoviDeCroock (See #2514)

2.0.1

Patch Changes

  • ⚠️ Fix Node.js ESM re-export detection for @urql/core in urql package and CommonJS output for all other CommonJS-first packages. This ensures that Node.js' cjs-module-lexer can correctly identify re-exports and report them properly. Otherwise, this will lead to a runtime error, by @kitten (See #2485)

2.0.0

Major Changes

  • Reimplement Svelte with functional-only API. We've gotten plenty of feedback and issues from the Svelte community about our prior Svelte bindings. These bindings favoured a Store singleton to read and write to, and a separate signal to start an operation. Svelte usually however calls for a lot more flexibility, so we're returning the API to a functional-only API again that serves to only create stores, which is more similar to the original implementation, by @jonathanstanley (See #2370)

Patch Changes

1.3.3

Patch Changes

  • Extend peer dependency range of graphql to include ^16.0.0. As always when upgrading across many packages of urql, especially including @urql/core we recommend you to deduplicate dependencies after upgrading, using npm dedupe or npx yarn-deduplicate, by @kitten (See #2133)
  • Updated dependencies (See #2133)

1.3.2

Patch Changes

  • ⚠️ Fix initialize operationStore with fetching: false, the invocation of query or any other operation will mark it as true when deemed appropriate, by @JoviDeCroock (See #2048)
  • Updated dependencies (See #2027 and #1998)

1.3.1

Patch Changes

1.3.0

Minor Changes

  • Improve granularity of operationStore updates when query, variables, and context are changed. This also adds an operationStore(...).reexecute() method, which optionally accepts a new context value and forces an update on the store, so that a query may reexecute, by @kitten (See #1780)

Patch Changes

  • Loosen subscription(...) type further to allow any operationStore input, regardless of the Result produced, by @kitten (See #1779)
  • Updated dependencies (See #1776 and #1755)

1.2.3

Patch Changes

  • Improve OperationStore and subscription types to allow for result types of data that differ from the original Data type, which may be picked up from TypedDocumentNode, by @kitten (See #1731)
  • Use client.executeMutation rather than client.mutation, by @JoviDeCroock (See #1732)
  • Updated dependencies (See #1709)

1.2.2

Patch Changes

1.2.1

Patch Changes

  • Allow mutation to accept a more partial GraphQLRequest object without a key or variables, by @JoviDeCroock (See #1473)

1.2.0

Minor Changes

  • Remove deprecated operationName property from Operations. The new Operation.kind property is now preferred. If you're creating new operations you may also use the makeOperation utility instead. When upgrading @urql/core please ensure that your package manager didn't install any duplicates of it. You may deduplicate it manually using npx yarn-deduplicate (for Yarn) or npm dedupe (for npm), by @kitten (See #1357)

Patch Changes

1.1.4

Patch Changes

  • Add a built-in gql tag function helper to @urql/core. This behaves similarly to graphql-tag but only warns about locally duplicated fragment names rather than globally. It also primes @urql/core's key cache with the parsed DocumentNode, by @kitten (See #1187)
  • Updated dependencies (See #1187, #1186, and #1186)

1.1.3

Patch Changes

1.1.2

Patch Changes

  • Replace void union types with undefined in OperationStore to allow nullish property access in TypeScript, by @kitten (See #1053)

1.1.1

Patch Changes

1.1.0

Minor Changes

  • Support passing pause to stop executing queries or subscriptions, by @kitten (See #1046)

Patch Changes

  • ⚠️ Fix an issue where updated context options wouldn't cause a new query to be executed, or updates to the store would erroneously throw a debug error, by @kitten (See #1046)

1.0.1

Patch Changes

  • ⚠️ Fix stale keeping a truthy value on a cache-and-network operation, by @JoviDeCroock (See #1032)

1.0.0

The new @urql/svelte API features the query, mutation, and subscription utilities, which are called as part of a component's normal lifecycle and accept operationStore stores. These are writable stores that encapsulate both a GraphQL operation's inputs and outputs (the result)! Learn more about how to use @urql/svelte in our new API docs or starting from the Basics pages.

Major Changes

  • Reimplement the @urql/svelte API, which is now marked as stable, by @kitten (See #1016)

0.4.0

Minor Changes

  • Add the operation to the query, mutation and subscription result, by @JoviDeCroock (See #924)

Patch Changes

0.3.0

Minor Changes

  • Refactor all operations to allow for more use-cases which preserve state and allow all modes of Svelte to be applied to urql.
    // Standard Usage:
    mutate({ query, variables })()
    // Subscribable Usage:
    $: result = mutate({ query, variables });
    // Curried Usage
    const executeMutation = mutate({ query, variables });
    const onClick = () => executeMutation();
    // Curried Usage with overrides
    const executeMutation = mutate({ query });
    const onClick = () => await executeMutation({ variables });
    // Subscribable Usage (as before):
    $: result = query({ query: TestQuery, variables });
    // Subscribable Usage which preserves state over time:
    const testQuery = query({ query: TestQuery });
    // - this preserves the state even when the variables change!
    $: result = testQuery({ variables });
    // Promise-based callback usage:
    const testQuery = query({ query: TestQuery });
    const doQuery = async () => await testQuery;
    // Promise-based usage updates the subscribables!
    const testQuery = query({ query: TestQuery });
    const doQuery = async () => await testQuery;
    // - doQuery will also update this result
    $: result = query({ query: TestQuery, variables });

Patch Changes

0.2.4

Patch Changes

  • Upgrade to a minimum version of wonka@^4.0.14 to work around issues with React Native's minification builds, which use uglify-es and could lead to broken bundles, by @kitten (See #842)
  • Updated dependencies (See #838 and #842)

0.2.3

Patch Changes

  • Add a "./package.json" entry to the package.json's "exports" field for Node 14. This seems to be required by packages like rollup-plugin-svelte to function properly, by @JoviDeCroock (See #771)
  • Updated dependencies (See #771)

0.2.2

Patch Changes

  • Update mutate helper to return a Promise directly rather than a lazy Promise-like object, by @JoviDeCroock (See #758)

0.2.1

Patch Changes

  • Bump @urql/core to ensure exchanges have dispatchDebug, this could formerly result in a crash, by @JoviDeCroock (See #726)

0.2.0

Minor Changes

  • Update mutate() API to accept an options argument, instead of separate arguments, to increase consistency, by @kitten (See #705)

0.1.3

Patch Changes

  • Add graphql@^15.0.0 to peer dependency range, by @kitten (See #688)
  • Forcefully bump @urql/core package in all bindings and in @urql/exchange-graphcache. We're aware that in some cases users may not have upgraded to @urql/core, even though that's within the typical patch range. Since the latest @urql/core version contains a patch that is required for cache-and-network to work, we're pushing another patch that now forcefully bumps everyone to the new version that includes this fix, by @kitten (See #684)
  • Updated dependencies (See #688 and #678)

0.1.2

Patch Changes

  • ⚠️ Fix node resolution when using Webpack, which experiences a bug where it only resolves package.json:main instead of module when an .mjs file imports a package, by @JoviDeCroock (See #642)
  • Updated dependencies (See #642)

0.1.1

Patch Changes

  • ⚠️ Fix Node.js Module support for v13 (experimental-modules) and v14. If your bundler doesn't support .mjs files and fails to resolve the new version, please double check your configuration for Webpack, or similar tools, by @JoviDeCroock (See #637)
  • Updated dependencies (See #637)

0.1.0

Patch Changes

0.1.0-alpha.0

Initial Alpha Release