openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

feat(openapi-react-query): support for useInfiniteQuery()

Open jungwoo3490 opened this issue 1 year ago • 1 comments

Changes

close #1828

Hi @kerwanp :)

I added useInfiniteQuery() to openapi-react-query.

How to Review

Any feedback is welcome. I'll review it and make updates!

Checklist

  • [x] Unit tests updated
  • [x] docs/ updated (if necessary)
  • [ ] pnpm run update:examples run (only applicable for openapi-typescript)

jungwoo3490 avatar Aug 27 '24 20:08 jungwoo3490

⚠️ No Changeset found

Latest commit: 688bc2f7003299272c162cb2f15947cd5429aa88

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Aug 27 '24 20:08 changeset-bot[bot]

@drwpow @kerwanp Can you check this PR? 👀

jungwoo3490 avatar Oct 14 '24 09:10 jungwoo3490

Is there any reason not to introduce this?

tommymarshall avatar Nov 14 '24 17:11 tommymarshall

@tommymarshall @jungwoo3490 this pull request does not seem to be ready to be merged as tests are still failing. And with the latest changes it now has conflicts with main branch.

I would be happy to review a pull request introducing those changes with successful tests and resolved conflicts.

kerwanp avatar Nov 15 '24 13:11 kerwanp

@tommymarshall @jungwoo3490 this pull request does not seem to be ready to be merged as tests are still failing. And with the latest changes it now has conflicts with main branch.

I would be happy to review a pull request introducing those changes with successful tests and resolved conflicts.

Looks like it it's a build error with existing code -- worth re-running or getting the branch up-to-date @jungwoo3490 ?

tommymarshall avatar Nov 18 '24 16:11 tommymarshall

@kerwanp @tommymarshall I'll update my branch and resolve the conflict as soon as possible!

jungwoo3490 avatar Nov 18 '24 17:11 jungwoo3490

Thank you for helping out @jungwoo3490! It would be a nice feature to have.

Mattias- avatar Dec 13 '24 10:12 Mattias-

@kerwanp @drwpow @tommymarshall I've resolved all the conflict errors and confirmed that it’s ready to merge into the main branch. Could you double-check again please?

jungwoo3490 avatar Dec 15 '24 07:12 jungwoo3490

I am confused, how do you use the pageParam in the request? It does not seem to be provided and there is no option to define where to use it (path params, query params, body)

kerwanp avatar Dec 21 '24 12:12 kerwanp

When will be released? Any news?

snndmnsz avatar Dec 28 '24 14:12 snndmnsz

Hi all, this hook is part of the core tanstack query and is one of the main reasons why devs choose tanstack query as opposed to other libs, I see a lot of work has been done already (Many thanks for them!) but we're wondering if we can help in anyway to have this merged? I, for one, would be very happy to help. Thanks.

MikeBurkeMed avatar Jan 18 '25 12:01 MikeBurkeMed

I managed to hack together a working implementation with a few tweaks from what has been done here. I quickly extracted this from some production code, so it will take some effort to get working for individual or project use cases.

This implementation makes some assumptions about the page param being in the query params rather than the body of a POST request. There are a few ignored types, the generated paths type doesn't align with the interface (Record<string, Record<HttpMethod, {}>>) defined by many of the internal types, so there're are some ignored type errors.

I know I have found a way in the past to convert a dot-separated string into an object path with TypeScript, something like that might also work for the page param so it doesn't need to be a function call, but could still support different params sources.

https://gist.github.com/awmichel/0e3aa3d5df6f7891e794895d2c695107

Edit: Ahh, yes, this StackOverflow post has some good references for strongly typed nested object paths. https://stackoverflow.com/questions/77976781/typescript-type-for-getting-all-nested-key-paths-of-an-object-including-arrays

awmichel avatar Jan 23 '25 00:01 awmichel

@awmichel

Thanks, this is really cool! Does the page param work only for query params, or can you use this for JSON bodies too?

musjj avatar Jan 23 '25 08:01 musjj

@musjj It only works for query params, but line 60 of the gist is where the page param is being merged into initWithPage, so if you consistently need the page param in a JSON body, you could change query to body on lines 58 and 59.

awmichel avatar Jan 23 '25 18:01 awmichel

Hey guys, I continued this PR here #2117, I really need this feature so any reviews are welcomed! Cc.: @HagenMorano @kerwanp @drwpow

lukasedw avatar Jan 24 '25 22:01 lukasedw