Replies: 1 comment
-
Thanks for bringing this up. I agree that this is confusing and adds unnecessary ambiguity to the response type. The reason the response is typed as type Todo = {
id: number
name: string
...
}
const [{ count, data, error, fetching }, reexecute] = useSelect<Todo>('todos', {
filter: (query) => query.eq('id', 123).single(),
})
// Access property: data.id ✅
// Not a list: data.length 🚫 I'm open to solutions: TypeScript wizardry, maybe a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As I've started using
useInsert
hook in the codebase I've noticed that the return type of execution function isData | Data[]
while the supabase api always responds withData[]
Sample response from single insert:
References
At the same time it's quite tedious task to do the distinction if the hook response is
Data
orData[]
in terms of types.Let's discuss some possible solutions to ease the development friction or to provide documentation for such cases.
Beta Was this translation helpful? Give feedback.
All reactions