From a23a78cea79a6c5dc3f994e0343d0798601076f2 Mon Sep 17 00:00:00 2001 From: WitherBlock Date: Tue, 4 Apr 2023 04:01:11 +0400 Subject: [PATCH] refactor: update react-query example to latest --- examples/react-query/README.md | 6 +++--- examples/react-query/package.json | 4 ++-- examples/react-query/src/App.tsx | 8 ++++---- examples/react-query/src/main.tsx | 2 +- yarn.lock | 30 ++++++++++++------------------ 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/examples/react-query/README.md b/examples/react-query/README.md index 377e5800..caf6390b 100644 --- a/examples/react-query/README.md +++ b/examples/react-query/README.md @@ -1,6 +1,6 @@ ### The Graph Client / React Query -This examples integrates The Graph Client with [React Query](https://react-query.tanstack.com/). +This examples integrates The Graph Client with [React Query](https://tanstack.com/query/latest/). The example here is using the following tools/concepts: @@ -8,7 +8,7 @@ The example here is using the following tools/concepts: - Client-side Compostion (more than 1 source) - Vite-based frontend project with TypeScript - GraphQL Codegen for type safe SDK -- [React Query](https://react-query.tanstack.com/) +- [React Query](https://tanstack.com/query/latest/) ### Getting Started @@ -18,7 +18,7 @@ To run this example, make sure to install the dependencies in the root of the mo # In the root directory $ yarn install $ yarn build -$ cd examples/urql/ +$ cd examples/react-query/ $ yarn build-client $ yarn start ``` diff --git a/examples/react-query/package.json b/examples/react-query/package.json index fad15f43..7356c46a 100644 --- a/examples/react-query/package.json +++ b/examples/react-query/package.json @@ -10,10 +10,10 @@ "graphiql": "graphclient serve-dev" }, "dependencies": { + "@tanstack/react-query": "4.28.0", "graphql": "16.6.0", "react": "18.2.0", - "react-dom": "18.2.0", - "react-query": "4.0.0" + "react-dom": "18.2.0" }, "devDependencies": { "@graphprotocol/client-cli": "2.2.20", diff --git a/examples/react-query/src/App.tsx b/examples/react-query/src/App.tsx index 94cbf6fe..70dcc177 100644 --- a/examples/react-query/src/App.tsx +++ b/examples/react-query/src/App.tsx @@ -1,12 +1,12 @@ import logo from './logo.svg' import './App.css' import { getBuiltGraphSDK } from '../.graphclient' -import { useQuery } from 'react-query' +import { useQuery } from '@tanstack/react-query' const sdk = getBuiltGraphSDK() function App() { - const result = useQuery('ExampleQuery', () => sdk.ExampleQuery()) + const result = useQuery({ queryKey: ['ExampleQuery'], queryFn: () => sdk.ExampleQuery() }) const { data, isLoading, error, refetch } = result return ( @@ -28,13 +28,13 @@ function App() {