···11+| Example | Description |
22+| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
33+| [`with-react`](./with-react) | Shows a basic query in `urql` with React. |
44+| [`with-react-native`](./with-react-native) | Shows a basic query in `urql` with React Native. |
55+| [`with-svelte`](./with-svelte) | Shows a basic query in `@urql/svelte` with Svelte. |
66+| [`with-vue3`](./with-vue3) | Shows a basic query in `@urql/vue` with Vue 3. |
77+| [`with-next`](./with-next) | Shows some examples with `next-urql` in Next.js with the default, `getStaticProps` and `getServerSideProps`. |
88+| [`with-pagination`](./with-pagination) | Shows how to generically set up infinite pagination with `urql` in UI code. |
99+| [`with-apq`](./with-apq) | Shows Automatic Persisted Queries with `@urql/exchange-persisted-fetch`. |
1010+| [`with-graphcache-updates`](./with-graphcache-updates) | Shows manual cache updates with `@urql/exchange-graphcache`. |
1111+| [`with-graphcache-pagination`](./with-graphcache-pagination) | Shows the automatic infinite pagination helpers from `@urql/exchange-graphcache`. |
1212+| [`with-multipart`](./with-multipart) | Shows file upload support with `@urql/exchange-multipart-fetch`. |
1313+| [`with-refresh-auth`](./with-refresh-auth) | Shows an example of authentication with refresh tokens using `@urql/exchange-auth`. |
1414+| [`with-retry`](./with-retry) | Shows how to set up `@urql/exchange-retry` for retrying failed operations. |
+16-16
examples/with-apq/README.md
···11-# Integrating with `@urql/exchange-persisted-fetch`’s persistedFetchExchange
22-33-Integrating urql is as simple as:
44-55-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
66-77-```sh
88-yarn add urql graphql
99-# or
1010-npm install --save urql graphql
1111-```
11+# With Automatic Persisted Queries
1221313-2. Then install the package for [automatic persisted queries](https://formidable.com/open-source/urql/docs/advanced/persistence-and-uploads/)
33+This example shows `urql` in use with `@urql/exchange-persisted-fetch`'s `persistedFetchExchange`
44+to support [Automatic Persisted
55+Queries](https://www.apollographql.com/docs/apollo-server/performance/apq/). This largely follows
66+the ["Persisted Queries" docs
77+page](https://formidable.com/open-source/urql/docs/advanced/persistence-and-uploads/#automatic-persisted-queries)
88+and uses the [`trygql.formidable.dev/graphql/apq-weather` schema](https://github.com/FormidableLabs/trygql).
1491010+To run this example install dependencies and run the `start` script:
15111612```sh
1717-yarn add @urql/exchange-persisted-fetch
1313+yarn install
1414+yarn run start
1815# or
1919-npm install --save @urql/exchange-persisted-fetch
1616+npm install
1717+npm run start
2018```
21192222-3. Setting up the Client and adding persistedFetchExchange [here](src/App.js)
2020+This example contains:
23212424-4. Execute the Query [here](src/pages/LocationsList.js)
2222+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
2323+- The `persistedFetchExchange` from `@urql/exchange-persisted-fetch` in [`src/App.js`](src/App.js)
2424+- A query for locations in [`src/pages/LocationsList.js`](src/pages/LocationsList.js)
···11import { Provider } from "urql";
2233-import client from './client';
33+import client from "./client";
44import Home from "./pages/Home";
5566function App() {
···11-# Integrating with `@urql/exchange-graphcache`'s cacheExchange pagination
22-33-Integrating urql is as simple as:
11+# With Graphcache's Pagination
4255-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
66-77-```sh
88-yarn add urql graphql
99-# or
1010-npm install --save urql graphql
1111-```
33+This example shows `urql` in use with `@urql/exchange-graphcache`'s infinite pagination helpers to
44+merge several pages of a Relay-compliant schema into an infinite list.
55+This largely follows the ["Pagination" section on the "Local Resolvers" docs
66+page](https://formidable.com/open-source/urql/docs/graphcache/local-resolvers/#pagination)
77+and uses the [`trygql.formidable.dev/graphql/relay-npm` schema](https://github.com/FormidableLabs/trygql).
1281313-2. Install [graphcache](https://formidable.com/open-source/urql/docs/graphcache/)
99+To run this example install dependencies and run the `start` script:
14101511```sh
1616-yarn add @urql/exchange-graphcache
1212+yarn install
1313+yarn run start
1714# or
1818-npm install --save @urql/exchange-graphcache
1515+npm install
1616+npm run start
1917```
20182121-3. Setting up the Client [here](src/App.js)
1919+This example contains:
22202323-4. Execute the Query [here](src/pages/PaginatedNpmSearch.js)
2121+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
2222+- The `cacheExchange` from `@urql/exchange-graphcache` in [`src/App.js`](src/App.js)
2323+- A paginated query for packages in [`src/pages/PaginatedNpmSearch.js`](src/pages/PaginatedNpmSearch.js)
···11+# With Graphcache's Pagination
22+33+This example shows `urql` in use with `@urql/exchange-graphcache` and demonstrates a manual cache
44+update, as explained in [the "Cache Updates" docs page](https://formidable.com/open-source/urql/docs/graphcache/cache-updates/).
55+This example uses the [`trygql.formidable.dev/graphql/web-collections`
66+schema](https://github.com/FormidableLabs/trygql) and builds on top of the [`with-refresh-auth`
77+example](../with-refresh-auth) so that we can authenticate with the schema before creating links on
88+it.
99+1010+To run this example install dependencies and run the `start` script:
1111+1212+```sh
1313+yarn install
1414+yarn run start
1515+# or
1616+npm install
1717+npm run start
1818+```
1919+2020+This example contains:
2121+2222+- The `urql` bindings and a React app with a client set up in [`src/client/index.js`](src/client/index.js)
2323+- The `cacheExchange` from `@urql/exchange-graphcache` in [`src/client/index.js`](src/client/index.js)
2424+- A links list and link creation in [`src/pages/Links.js`](src/pages/Links.js)
+14-14
examples/with-multipart/README.md
···11-# Integrating with `@urql/exchange-multipart-fetch`'s multipartFetchExchange
11+# With Multipart File Upload
2233-Integrating urql is as simple as:
33+This example shows `urql` in use with `@urql/exchange-multipart-fetch`'s `multipartFetchExchange`
44+to support file uploads in GraphQL. This largely follows the ["File Uploads" docs
55+page](https://formidable.com/open-source/urql/docs/advanced/persistence-and-uploads/)
66+and uses the [`trygql.formidable.dev/graphql/uploads-mock` schema](https://github.com/FormidableLabs/trygql).
4755-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
88+To run this example install dependencies and run the `start` script:
69710```sh
88-yarn add urql graphql
99-# or
1010-npm install --save urql graphql
1111-```
1212-1313-2. Add [multipart exchange](https://formidable.com/open-source/urql/docs/advanced/persistence-and-uploads/)
1414-1515-```yarn add @urql/exchange-multipart-fetch
1111+yarn install
1212+yarn run start
1613# or
1717-npm install --save @urql/exchange-multipart-fetch
1414+npm install
1515+npm run start
1816```
19172020-3. Setting up the Client [here](src/App.js)
1818+This example contains:
21192222-4. Execute the Mutation [here](src/pages/FileUpload.js)
2020+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
2121+- The `multipartFetchExchange` from `@urql/exchange-multipart-fetch` in [`src/App.js`](src/App.js)
2222+- A basic file upload form in [`src/pages/FileUpload.js`](src/pages/FileUpload.js)
···11-# Integrating with Next
11+# With Next.js
22+33+This example shows `next-urql` and `urql` in use with Next.js as explained [in the "Next.js" section
44+on the "Server-side Rendering" docs
55+page](https://formidable.com/open-source/urql/docs/advanced/server-side-rendering/#nextjs).
66+77+To run this example install dependencies and run the `start` script:
88+99+```sh
1010+yarn install
1111+yarn run start
1212+# or
1313+npm install
1414+npm run start
1515+```
216317## getInitialProps
418
···11-# Integrating with React
11+# With Pagination (in React)
2233-Integrating urql is as simple as:
33+This example shows how to implement infinite pagination with `urql` in your React UI code. It
44+renders several pages as fragments with one component managing the variables for the page queries.
55+This example is also reapplicable to other libraries, like Svelte or Vue.
4655-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
77+To run this example install dependencies and run the `start` script:
6879```sh
88-yarn add urql graphql
1010+yarn install
1111+yarn run start
912# or
1010-npm install --save urql graphql
1313+npm install
1414+npm run start
1115```
12161313-2. Setting up the Client [here](src/App.js)
1717+This example contains:
14181515-3. Execute the Query [here](src/pages/PaginatedNpmSearch.js)
1919+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
2020+- A managing component called `PaginatedNpmSearch` set up to render all pages in [`src/PaginatedNpmSearch.js`](src/PaginatedNpmSearch.js)
2121+- A page component called `SearchResultPage` running page queries in [`src/PaginatedNpmSearch.js`](src/PaginatedNpmSearch.js)
···11-# Integrating with React Native
11+# With React Native
2233-Integrating urql is as simple as:
33+This example shows `urql` in use with React Native.
4455-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
55+To run this example install dependencies and run the `start` script:
6677```sh
88-yarn add urql graphql
88+yarn install
99+yarn run start
910# or
1010-npm install --save urql graphql
1111+npm install
1212+npm run start
1113```
12141313-2. Setting up the Client [here](App.js)
1515+This example contains:
14161515-3. Execute the Query [here](src/screens/PokemonList.js)
1717+- The `urql` bindings and a React Native app with a client set up in [`src/App.js`](src/App.js)
1818+- A query for pokémon in [`src/screens/PokemonList.js`](src/screens/PokemonList.js)
···11-# Integrating with React
11+# With React
2233-Integrating urql is as simple as:
33+This example shows `urql` in use with React, as explained on the ["React/Preact" page of the "Basics"
44+documentation.](https://formidable.com/open-source/urql/docs/basics/react-preact/)
4555-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
66+To run this example install dependencies and run the `start` script:
6778```sh
88-yarn add urql graphql
99+yarn install
1010+yarn run start
911# or
1010-npm install --save urql graphql
1212+npm install
1313+npm run start
1114```
12151313-2. Setting up the Client [here](src/App.js)
1616+This example contains:
14171515-3. Execute the Query [here](src/pages/PokemonList.js)
1818+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
1919+- A query for pokémon in [`src/pages/PokemonList.js`](src/pages/PokemonList.js)
···11-# Integrating with `@urql/exchange-auth`'s authExchange
11+# With Refresh Authentication
2233-Integrating urql is as simple as:
33+This example shows `urql` in use with `@urql/exchange-auth`'s `authExchange`
44+to support authentication token and refresh token logic. This largely follows the ["Authentication" docs
55+page](https://formidable.com/open-source/urql/docs/advanced/authentication/)
66+and uses the [`trygql.formidable.dev/graphql/web-collections` schema](https://github.com/FormidableLabs/trygql).
4755-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/react-preact/)
88+To run this example install dependencies and run the `start` script:
69710```sh
88-yarn add urql graphql
1111+yarn install
1212+yarn run start
913# or
1010-npm install --save urql graphql
1414+npm install
1515+npm run start
1116```
12171313-2. Install [authExchange](https://formidable.com/open-source/urql/docs/advanced/authentication/)
1818+This example contains:
14191515-```sh
1616-yarn add @urql/exchange-auth
1717-# or
1818-npm install --save @urql/exchange-auth
1919-```
2020-2121-3. Setting up the Client and setup the Auth flow [here](src/App.js)
2020+- The `urql` bindings and a React app set up in [`src/App.js`](src/App.js)
2121+- Some authentication glue code to store the tokens in [`src/auth/Store.js`](src/auth/Store.js)
2222+- The `Client` and the `authExchange` from `@urql/exchange-auth` set up in [`src/client/index.js`](src/client/index.js)
2323+- A basic login form in [`src/pages/LoginForm.js`](src/pages/LoginForm.js)
2424+- And a basic login guard on [`src/pages/Home.js`](src/pages/Home.js)
2525+ (Note: This isn't using a query in this particular component, since this is just an example)
···21213. Setting up the Client and adding the `retryExchange` [here](src/App.js)
222223234. Execute the Query [here](src/pages/Color.js)
2424+2525+# With Retry
2626+2727+This example shows `urql` in use with `@urql/exchange-retry`'s `retryExchange`
2828+to implement retrying failed operations. This largely follows the ["Retrying Operations" docs
2929+page](https://formidable.com/open-source/urql/docs/advanced/retry-operations/)
3030+and uses the [`trygql.formidable.dev/graphql/intermittent-colors`
3131+schema](https://github.com/FormidableLabs/trygql), which emits a special `NO_SOUP` error randomly.
3232+3333+To run this example install dependencies and run the `start` script:
3434+3535+```sh
3636+yarn install
3737+yarn run start
3838+# or
3939+npm install
4040+npm run start
4141+```
4242+4343+This example contains:
4444+4545+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.js)
4646+- The `retryExchange` from `@urql/exchange-retry` in [`src/App.js`](src/App.js)
4747+- A random colour query in [`src/pages/Color.js`](src/pages/Color.js)
···44import Color from "./pages/Color";
5566const client = createClient({
77- url: "https://trygql.dev/graphql/intermittent-colors",
77+ url: "https://trygql.formidable.dev/graphql/intermittent-colors",
88 exchanges: [
99 retryExchange({
1010 maxNumberAttempts: 5,
1111 retryIf: error => {
1212- return error.graphQLErrors.length || error.networkError;
1212+ // NOTE: With this deemo schema we have a specific random error to look out for:
1313+ return error.graphQLErrors.some(x => x.extensions?.code === 'NO_SOUP')
1414+ || !!error.networkError;
1315 }
1414- }), // Use the retryExchange factory to add a new exchange,
1616+ }),
1517 fetchExchange
1618 ],
1719});
+11-7
examples/with-svelte/README.md
···11-# Integrating with React
11+# With Svelte
2233-Integrating urql is as simple as:
33+This example shows `@urql/svelte` in use with Svelte, as explained on the ["Svelte" page of the "Basics"
44+documentation.](https://formidable.com/open-source/urql/docs/basics/svelte/)
4555-1. Install packages [getting started](https://formidable.com/open-source/urql/docs/basics/svelte/)
66+To run this example install dependencies and run the `start` script:
6778```sh
88-yarn add @urql/svelte graphql
99+yarn install
1010+yarn run start
911# or
1010-npm install --save @urql/svelte graphql
1212+npm install
1313+npm run start
1114```
12151313-2. Setting up the Client [here](src/App.svelte)
1616+This example contains:
14171515-3. Execute the Query [here](src/App.svelte)
1818+- The `@urql/svelte` bindings with a client set up in [`src/App.svelte`](src/App.svelte)
1919+- A query for pokémon in [`src/PokemonList.svelte`](src/pages/PokemonList.svelte)
···11+# With Vue 3
22+33+This example shows `@urql/vue` in use with Vue 3, as explained on the ["Vue" page of the "Basics"
44+documentation.](https://formidable.com/open-source/urql/docs/basics/vue/)
55+66+To run this example install dependencies and run the `start` script:
77+88+```sh
99+yarn install
1010+yarn run start
1111+# or
1212+npm install
1313+npm run start
1414+```
1515+1616+This example contains:
1717+1818+- The `@urql/vue` bindings with a client set up in [`src/App.vue`](src/App.vue)
1919+- A suspense loading boundary in the `App` component in [`src/App.vue`](src/App.vue)
2020+- A query for pokémon in [`src/PokemonList.vue`](src/pages/PokemonList.vue)