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

Fix types when using select with queries #14

Merged
merged 2 commits into from
Nov 12, 2023
Merged

Conversation

HugeLetters
Copy link
Contributor

@HugeLetters HugeLetters commented Nov 5, 2023

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
Owner

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

@HugeLetters
Copy link
Contributor Author

HugeLetters commented Nov 7, 2023

@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