Skip to content

All query hooks must support undefined arguments #135

@dalechyn

Description

@dalechyn

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions