Proposal: Make WatchQueryOptions's variable field optional#351
Proposal: Make WatchQueryOptions's variable field optional#351chuganzy wants to merge 3 commits intoheftapp:mainfrom
WatchQueryOptions's variable field optional#351Conversation
|
Thank you for taking the time to write up this PR, @chuganzy! If we make the variables optional on the watch query, then I would make the "watches" invalid until you've mutated the variables. What I mean is that the result of the If I understand your example correctly, you are trying to re-fetch data after an action (effect in your case, but it could just as well have been a user action); for this, I would usually use the client directly. class Widget {
Widget build(BuildContext context) {
final client = useGraphQLClient()
useEffect(() {
fetch() async {
final resolvedRequiredValue = await something;
await client.queryXXX( ... )
}
fetch();
}, [query]);
}
...
}
Does this solve your problem or am I missing something? |
|
@budde377 Thank you for the reply! As you pointed out,
but, once it runs the query, the stream sends the first result and can update the view (widget) accordingly. This is why I think the By doing it, we can also easily create something similar to Apollo's Please let me know how you think. Thank you again! |
Thank you for creating this amazing tool and publishing it, we've been loving it!
As titled, this PR is a proposal to make
variablefield inWatchQueryOption$XXXoptional.It makes sense to make
variablerequired forquerybecause it starts the request as soon asqueryis called, however sincewatchcan run lazily, it is more useful for us to make it blank at first, and fill once it is ready.This is especially useful when using with hooks (ex:
useWatchQuery) where some parts ofvariablesare not available on Widget's mount.Please have a look and let me know! Thank you!