question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reexecuteQuery for jotai/urql

See original GitHub issue

Do I understand correctly that there is no mechanism at all to reexecute a query in jotai/urql? In the regular urql hooks there is this method: https://formidable.com/open-source/urql/docs/basics/react-preact/#reexecuting-queries

const Todos = ({ from, limit }) => {
  const [result, reexecuteQuery] = useQuery({
    query: TodosListQuery,
    variables: { from, limit },
  });

  const refresh = () => {
    // Refetch the query and skip the cache
    reexecuteQuery({ requestPolicy: 'network-only' });
  };
};

Not being able to reexecute queries seems like a rather big limitation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
israelidannycommented, Aug 26, 2021

That util would be the perfect temporary measure for now, until the world figures out new design patterns 👍

You’re absolutely right, this is a case of a future pattern not yet having gone through enough discovery to find all the right use cases.

However, combined with a util like that one, this makes it perfectly usable in the real world. I’ll jump over there and see what the state of it is.

On Thu, Aug 26, 2021, 06:56 Daishi Kato @.***> wrote:

Yeah, fetching is in react-urql. jotai atoms are designed for Suspense and useTransition, which might be too futuristic for now. I understand that distinguishing between the initial fetching and refetching is important in the real use case. We hope to come up with some ideas for both jotai/urql and jotai/query. btw, you might be interested in the new util at #672 https://github.com/pmndrs/jotai/issues/672. Actually, it could solve refetching issue there.

Apart from jotai, I wonder how drag to refersh and background refetch will be implemented as best practices in Suspense era.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pmndrs/jotai/issues/666#issuecomment-906073271, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPBB6ANMLCQ7HAAQTYYB6DT6W3QDANCNFSM5COK5IYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

0reactions
dai-shicommented, Aug 26, 2021

Yeah, fetching is in react-urql. jotai atoms are designed for Suspense and useTransition, which might be too futuristic for now. I understand that distinguishing between the initial fetching and refetching is important in the real use case. We hope to come up with some ideas for both jotai/urql and jotai/query. btw, you might be interested in the new util at #672. Actually, it could solve refetching issue there.

Apart from jotai, I wonder how drag to refersh and background refetch will be implemented as best practices in Suspense era.

Read more comments on GitHub >

github_iconTop Results From Across the Web

URQL — Jotai, primitive and flexible state management for ...
atomsWithQuery creates new atoms with a query. It internally uses client.query. import { useAtom } from 'jotai'. import { createClient } from '@urql/core'....
Read more >
urql Documentation - React API
The query to be executed. Accepts as a plain string query or GraphQL DocumentNode. variables ?object, The variables to be used with the...
Read more >
Why We Need Jotai v2 API - Daishi Kato's blog
Jotai is a library for React state management. ... We call this behavior “extra re-renders without commits”, and it's an expected behavior ...
Read more >
jotai/urql.mjs - UNPKG
81, case "reexecute": {. 82, const queryResult = get(queryResultAtom);. 83, if (!queryResult) {. 84, throw new Error("query is paused");.
Read more >
Jotai (@jotaijs) / Twitter
Call for document contributors · Discussion #1627 · pmndrs/jotai ... There has been many feature requests for jotai/query and jotai/urql which exceed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found