···19192020This example contains:
21212222-- 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)
2222+- The `urql` bindings and a React app with a client set up in [`src/App.jsx`](src/App.jsx)
2323+- The `persistedFetchExchange` from `@urql/exchange-persisted-fetch` in [`src/App.jsx`](src/App.jsx)
2424+- A query for locations in [`src/LocationsList.jsx`](src/pages/LocationsList.jsx)
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});
+3-3
examples/with-graphcache-updates/README.md
···19192020This example contains:
21212222-- 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)
2222+- The `urql` bindings and a React app with a client set up in [`src/client.js`](src/client.js)
2323+- The `cacheExchange` from `@urql/exchange-graphcache` in [`src/client.js`](src/client.js)
2424+- A links list and link creation in [`src/pages/Links.jsx`](src/pages/Links.jsx)
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});
+3-3
examples/with-multipart/README.md
···17171818This example contains:
19192020-- 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)
2020+- The `urql` bindings and a React app with a client set up in [`src/App.jsx`](src/App.jsx)
2121+- The `multipartFetchExchange` from `@urql/exchange-multipart-fetch` in [`src/App.jsx`](src/App.jsx)
2222+- A basic file upload form in [`src/FileUpload.jsx`](src/FileUpload.jsx)
···11-import { initUrqlClient } from "next-urql";
11+import { initUrqlClient } from 'next-urql';
22import {
33 ssrExchange,
44 dedupExchange,
55 cacheExchange,
66 fetchExchange,
77 useQuery,
88- gql
99-} from "urql";
88+ gql,
99+} from 'urql';
10101111const POKEMONS_QUERY = gql`
1212 query {
···2323 return (
2424 <div>
2525 <h1>Server-side render</h1>
2626- {res.data.pokemons.map((pokemon) => (
2626+ {res.data.pokemons.map(pokemon => (
2727 <div key={pokemon.id}>
2828 {pokemon.id} - {pokemon.name}
2929 </div>
···34343535export async function getServerSideProps() {
3636 const ssrCache = ssrExchange({ isClient: false });
3737- const client = initUrqlClient({
3838- url: "https://trygql.formidable.dev/graphql/basic-pokedex",
3939- exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange]
4040- }, false);
3737+ const client = initUrqlClient(
3838+ {
3939+ url: 'https://trygql.formidable.dev/graphql/basic-pokedex',
4040+ exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange],
4141+ },
4242+ false
4343+ );
41444245 // This query is used to populate the cache for the query
4346 // used on this page.
···4649 return {
4750 props: {
4851 // urqlState is a keyword here so withUrqlClient can pick it up.
4949- urqlState: ssrCache.extractData()
5252+ urqlState: ssrCache.extractData(),
5053 },
5154 };
5255}
+12-9
examples/with-next/pages/static.js
···11-import { initUrqlClient } from "next-urql";
11+import { initUrqlClient } from 'next-urql';
22import {
33 ssrExchange,
44 dedupExchange,
55 cacheExchange,
66 fetchExchange,
77 useQuery,
88- gql
99-} from "urql";
88+ gql,
99+} from 'urql';
10101111const POKEMONS_QUERY = gql`
1212 query {
···2323 return (
2424 <div>
2525 <h1>Static</h1>
2626- {res.data.pokemons.map((pokemon) => (
2626+ {res.data.pokemons.map(pokemon => (
2727 <div key={pokemon.id}>
2828 {pokemon.id} - {pokemon.name}
2929 </div>
···34343535export async function getStaticProps() {
3636 const ssrCache = ssrExchange({ isClient: false });
3737- const client = initUrqlClient({
3838- url: "https://trygql.formidable.dev/graphql/basic-pokedex",
3939- exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange]
4040- }, false);
3737+ const client = initUrqlClient(
3838+ {
3939+ url: 'https://trygql.formidable.dev/graphql/basic-pokedex',
4040+ exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange],
4141+ },
4242+ false
4343+ );
41444245 // This query is used to populate the cache for the query
4346 // used on this page.
···4649 return {
4750 props: {
4851 // urqlState is a keyword here so withUrqlClient can pick it up.
4949- urqlState: ssrCache.extractData()
5252+ urqlState: ssrCache.extractData(),
5053 },
5154 };
5255}
+3-3
examples/with-pagination/README.md
···16161717This example contains:
18181919-- 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)
1919+- The `urql` bindings and a React app with a client set up in [`src/App.js`](src/App.jsx)
2020+- A managing component called `PaginatedNpmSearch` set up to render all pages in [`src/PaginatedNpmSearch.jss`](src/PaginatedNpmSearch.jsx)
2121+- A page component called `SearchResultPage` running page queries in [`src/PaginatedNpmSearch.jsx`](src/PaginatedNpmSearch.jsx)
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});
+2-2
examples/with-react/README.md
···15151616This example contains:
17171818-- 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)
1818+- The `urql` bindings and a React app with a client set up in [`src/App.jsx`](src/App.jsx)
1919+- A query for pokémon in [`src/PokemonList.jsx`](src/PokemonList.jsx)
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});
+5-5
examples/with-refresh-auth/README.md
···17171818This example contains:
19192020-- 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)
2020+- The `urql` bindings and a React app set up in [`src/App.jsx`](src/App.jsx)
2121+- Some authentication glue code to store the tokens in [`src/authStore.js`](src/authStore.js)
2222+- The `Client` and the `authExchange` from `@urql/exchange-auth` set up in [`src/client.js`](src/client.js)
2323+- A basic login form in [`src/pages/LoginForm.jsx`](src/pages/LoginForm.jsx)
2424+- And a basic login guard on [`src/App.jsx`](src/App.jsx)
2525 (Note: This isn't using a query in this particular component, since this is just an example)
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});
+3-3
examples/with-retry/README.md
···42424343This example contains:
44444545-- 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)
4545+- The `urql` bindings and a React app with a client set up in [`src/App.jsx`](src/App.jsx)
4646+- The `retryExchange` from `@urql/exchange-retry` in [`src/App.jsx`](src/App.jsx)
4747+- A random colour query in [`src/Color.jsx`](src/pages/Color.jsx)
···11-import React from "react";
22-import { gql, useQuery } from "urql";
11+import React from 'react';
22+import { gql, useQuery } from 'urql';
3344const RANDOM_COLOR_QUERY = gql`
55 query RandomColor {
···2626 {data.randomColor.name}
2727 </div>
2828 )}
2929-2929+3030 {result.operation && (
3131- <p>We retried {result.operation.context.retryCount} times to get a result without an error.</p>
3131+ <p>
3232+ We retried {result.operation.context.retryCount} times to get a result
3333+ without an error.
3434+ </p>
3235 )}
3336 </div>
3437 );
+7
examples/with-retry/vite.config.js
···11+import { defineConfig } from 'vite';
22+import reactRefresh from '@vitejs/plugin-react-refresh';
33+44+// https://vitejs.dev/config/
55+export default defineConfig({
66+ plugins: [reactRefresh()],
77+});