Skip to content

Fix types when using select with queries - #14

Merged
ottomated merged 2 commits into
ottomated:mainfrom
HugeLetters:main
Nov 12, 2023
Merged

ottomated merged 2 commits into
ottomated:mainfrom
HugeLetters:main

Conversation

@HugeLetters

@HugeLetters HugeLetters commented Nov 5, 2023 •

Copy link
Copy Markdown
Contributor

Currently when select transforms data shape(say, you fetch an array but then use select to get its length) - typescript will complain that select's return type is incompatible with data type.
This PR addressed that - now if you don't use select the type will be kept as is from procedure output. If you do - query data property type will be of whatever is returned by select function

Also fixed key type a little bit - it doesn't get inferred literally even tho theoretically that's doable(user.reviews.findAll -> [['user','reviews','findAll']] can be done), but at least it's of your QueryKey type instead of unknown now.

Also closes #10 - infinite queries now return correct type with page and page params and also next page parameter gets inferred correctly from cursor instead of unkown.

@ottomated

Copy link
Copy Markdown
Owner

Can you give an example of broken code for the select point?

@HugeLetters

HugeLetters commented Nov 7, 2023 •

Copy link
Copy Markdown
Contributor Author

@ottomated sure, here's a basic example

image
image
image

Now with my fix select doesn't error and query.data becomes number.

@ottomated
ottomated merged commit 1585a24 into ottomated:main Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite query type

2 participants