Skip to content

Commit d6d5b4d

Browse files
authored
refactor: update react-query example to latest (#415)
1 parent 75e40bf commit d6d5b4d

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

examples/react-query/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
### The Graph Client / React Query
22

3-
This examples integrates The Graph Client with [React Query](https://react-query.tanstack.com/).
3+
This examples integrates The Graph Client with [React Query](https://tanstack.com/query/latest/).
44

55
The example here is using the following tools/concepts:
66

77
- The Graph Client CLI for generating artifacts
88
- Client-side Compostion (more than 1 source)
99
- Vite-based frontend project with TypeScript
1010
- GraphQL Codegen for type safe SDK
11-
- [React Query](https://react-query.tanstack.com/)
11+
- [React Query](https://tanstack.com/query/latest/)
1212

1313
### Getting Started
1414

@@ -18,7 +18,7 @@ To run this example, make sure to install the dependencies in the root of the mo
1818
# In the root directory
1919
$ yarn install
2020
$ yarn build
21-
$ cd examples/urql/
21+
$ cd examples/react-query/
2222
$ yarn build-client
2323
$ yarn start
2424
```

examples/react-query/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"graphiql": "graphclient serve-dev"
1111
},
1212
"dependencies": {
13+
"@tanstack/react-query": "4.28.0",
1314
"graphql": "16.6.0",
1415
"react": "18.2.0",
15-
"react-dom": "18.2.0",
16-
"react-query": "4.0.0"
16+
"react-dom": "18.2.0"
1717
},
1818
"devDependencies": {
1919
"@graphprotocol/client-cli": "2.2.20",

examples/react-query/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import logo from './logo.svg'
22
import './App.css'
33
import { getBuiltGraphSDK } from '../.graphclient'
4-
import { useQuery } from 'react-query'
4+
import { useQuery } from '@tanstack/react-query'
55

66
const sdk = getBuiltGraphSDK()
77

88
function App() {
9-
const result = useQuery('ExampleQuery', () => sdk.ExampleQuery())
9+
const result = useQuery({ queryKey: ['ExampleQuery'], queryFn: () => sdk.ExampleQuery() })
1010

1111
const { data, isLoading, error, refetch } = result
1212
return (
@@ -28,13 +28,13 @@ function App() {
2828
<textarea value={JSON.stringify(data, null, 2)} readOnly rows={25} />
2929
</form>
3030
)}
31-
{error && (
31+
{error ? (
3232
<form>
3333
<label>Error</label>
3434
<br />
3535
<textarea value={JSON.stringify(error, null, 2)} readOnly rows={25} />
3636
</form>
37-
)}
37+
) : null}
3838
</fieldset>
3939
</header>
4040
</div>

examples/react-query/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'
33
import './index.css'
44
import App from './App'
55
import './App.css'
6-
import { QueryClient, QueryClientProvider } from 'react-query'
6+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
77

88
const queryClient = new QueryClient()
99

yarn.lock

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,10 +2688,18 @@
26882688
dependencies:
26892689
tslib "^2.4.0"
26902690

2691-
"@tanstack/query-core@^4.0.0-beta.1":
2692-
version "4.0.0"
2693-
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-4.0.0.tgz#76ee3707d237715b446044305fd5ae2bcc740b2c"
2694-
integrity sha512-EwapQGCC3TLK3ciedzcqXhlxQkGJ9GYe92ayxN+F+UCgQJWzpyp7Qez5bCTiSQLONM2Pg1Q6oDchpgd+ny2Wmg==
2691+
"@tanstack/[email protected]":
2692+
version "4.27.0"
2693+
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-4.27.0.tgz#96bcef499008ea080b66611d029655e3ffdf8bea"
2694+
integrity sha512-sm+QncWaPmM73IPwFlmWSKPqjdTXZeFf/7aEmWh00z7yl2FjqophPt0dE1EHW9P1giMC5rMviv7OUbSDmWzXXA==
2695+
2696+
"@tanstack/[email protected]":
2697+
version "4.28.0"
2698+
resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-4.28.0.tgz#01cb9969b15cbcbd5dcfcd4b264dc18ef0a35f86"
2699+
integrity sha512-8cGBV5300RHlvYdS4ea+G1JcZIt5CIuprXYFnsWggkmGoC0b5JaqG0fIX3qwDL9PTNkKvG76NGThIWbpXivMrQ==
2700+
dependencies:
2701+
"@tanstack/query-core" "4.27.0"
2702+
use-sync-external-store "^1.2.0"
26952703

26962704
"@tsconfig/node10@^1.0.7":
26972705
version "1.0.8"
@@ -2880,11 +2888,6 @@
28802888
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
28812889
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==
28822890

2883-
"@types/use-sync-external-store@^0.0.3":
2884-
version "0.0.3"
2885-
resolved "https://registry.yarnpkg.com/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz#b6725d5f4af24ace33b36fafd295136e75509f43"
2886-
integrity sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==
2887-
28882891
"@types/ws@^8.0.0":
28892892
version "8.5.0"
28902893
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.0.tgz#805ceb3f68eaebbed1a3004a66f16e35b7f3bf14"
@@ -6956,15 +6959,6 @@ [email protected]:
69566959
resolved "https://registry.yarnpkg.com/react-native-path/-/react-native-path-0.0.5.tgz#a04e4b73a535a8a7cf15c6e760e27db7789afb13"
69576960
integrity sha1-oE5Lc6U1qKfPFcbnYOJ9t3ia+xM=
69586961

6959-
6960-
version "4.0.0"
6961-
resolved "https://registry.yarnpkg.com/react-query/-/react-query-4.0.0.tgz#d8a5347503d0aedebc957e35b408c4aa3f726580"
6962-
integrity sha512-qiW+Yvbl+EK8iwPDJAj4qWAKceh+g8Up8jxoNxJbzhV3bNheeyHF3EyynnkDO3S+CYgSwtCUFaP8vOjB62j7xQ==
6963-
dependencies:
6964-
"@tanstack/query-core" "^4.0.0-beta.1"
6965-
"@types/use-sync-external-store" "^0.0.3"
6966-
use-sync-external-store "^1.2.0"
6967-
69686962
react-refresh@^0.14.0:
69696963
version "0.14.0"
69706964
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"

0 commit comments

Comments
 (0)