-
-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local state management #323
Comments
Hiya, there's no additional package yet that implements it, but there very well could be in the future. While it's unlikely that we'll pick this effort up ourselves and put it on our road map, we'd be happy to support anyone else who want to make this happen 👍 We're currently working on more documentation regarding how to write exchanges. |
@kitten Was thinking about this too. Did someone take it up? And is there a way to see different community-made exchanges? |
Hey @deadcoder0904 We have: https://github.com/FormidableLabs/urql/blob/master/docs/guides.md as guides to help you out with writing exchanges. There could be more but not that I know of at this moment. |
I am trying to choose a client for my react app. is this feature not yet implemented ? |
@ahmedosama5200 Go Zustand https://github.com/pmndrs/zustand or React Query https://github.com/tannerlinsley/react-query |
I am aiming for a more full-featured graphql-specific client. I know apollo but thinking about using urql |
@ ahmedosama5200 URQL has no local state (as far as I know), but only cache. |
Hey @ahmedosama5200 Currently we don't have a first-party integration for client-side extensions to the server-based schema, we haven't prioritized this since we have yet to see a good use case for this. We currently advise on React-state or one of the many local-state libraries out there in the wild. That being said it's always possible to implement this with an exchange as explored in #462, our extensibility pattern called exchanges allows for almost anything. |
It's also worth noting (to lift this from our other responses) that we don't believe in local state management in GraphQL clients or expressed in GraphQL itself. Ultimately It's advantageous to use GraphQL to your advantage to model data requirements and to fulfil them with a client. For more complex use cases we've got Graphcache, our normalised cache, for this task. Local state is better expressed in existing React hooks tools or libraries that do focus on local state, like Zustand for instance. If you combine server state and client state (or even UI state and server state) there's IMO not much to gain but much to lose in terms of coupling and "muddying" the otherwise clean nature of server state flowing down your element tree. |
Apollo and urql seem very similar to me. I feel like I already know urql because I know apollo except for little terminology(links become exchanges and so on), so migrations between the two, anytime down the road, will be easy, I guess I think my algorithm will go like this:
|
@kitten what is "the preferred urql way" to populate client state via urql? Let's say a form or something that is managed via redux and populated via urql from the server. Now I've resorted to some |
TBH this is the only thing that is a bit sad. That you cannot just use data from A good example would be starting a query, suspending the tree, and then getting a bunch of calculated fields and other things from the data from the query. Obviously, we need to strive to have all the calculations serverside, but sometimes some small silly things are fine to calculate on the client. It may also be useful in the scenario of rerender optimization too, as components can subscribe only to changes of the subset of the data from the query at any level using some It's obviously hard to incorporate correctly into Redux and whatnot, knowing, more or less, how URQL is working internally. In a sense that current React bindings are tracking currently listened-to operations via provided hooks, and refetch them in case let's say Having some Primitive bindings to Redux and whatnot should be not so hard to implement, but correct and full-featured bindings are gonna be tricky 100% (saying that as an author of |
Hello,
Is there a local state? Something like apollo-link-state? 😇
Thanks!
Maxim
The text was updated successfully, but these errors were encountered: