Skip to content
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

All query hooks must support undefined arguments #135

Open
dalechyn opened this issue Feb 7, 2024 · 0 comments
Open

All query hooks must support undefined arguments #135

dalechyn opened this issue Feb 7, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@dalechyn
Copy link
Contributor

dalechyn commented Feb 7, 2024

Is your feature request related to a problem? Please describe.

https://graz.sh/docs/hooks/useBalance

Take a look at useBalance hook. It requires a denom to be defined, but what the denom isn't statically available and it's a subject of a fetch? In other words, how do I use the hook if denom isn't yet defined?

Turns out graz doesn't support undefined arguments, so ALL the queries that depend on statically known arguments are not usable in such cases.
...

Describe the solution you'd like

wagmi supports undefined arguments in queries as they have a common query hook input interface of {args:Something[] | undefined}.

However, an array is used in their case as they dynamically retrieve the type of the query from ABI, which is not the case for graz.

As an opposite, for such hooks, graz has to either support undefineable arguments { something: Type | undefined } to enforce a user to pass some value which might be undefined as opposed to passing { something?: Type } which would make an argument partial and would confuse the developer wether he has passed sufficient input or not.

Therefore queries have to check for the input to be sufficient, and unless it is, return undefined and never enable the query.

Another approach could involve a breaking change and defining a common interface of { args: Input | undefined } that could simplify the input checking for graz developers, but that is probably would not be considered.

@codingki codingki self-assigned this Feb 14, 2024
@codingki codingki added the enhancement New feature or request label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants