Hey minester16 recursion in the TS SDK
Hey @minester16 , recursion in the TS SDK is indeed limited to two levels (so it will go up to currentTable.two.three). We created an issue in the client-ts repo https://github.com/xataio/client-ts/issues/1221 for the SDK dev team to include in their work planning as I believe there is some performance optimization that we may need to look into before enabling deeper recursion. You can follow that issue for updates!
4 Replies
@minester16 we discussed the issue and our findings are that depending on the complexity of the schema and the "loops" links generate, some IDEs encounter performance issues or even crash beyond some level of recursion. It seems relatively safe to "bump" recursion one more level, which would make things work for the issue you encountered. We're aiming to do that with the next release, but we'll also add a docs note about this limitation. This only causes TS types to "complain", but the actual queries work no matter the link depth.
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
I'll cross check with the dev team if there's a way to pass a custom type to the SDK, but my personal hunch is it requires manual validation
Since recursion was increased to 3 levels however with this PR: https://github.com/xataio/client-ts/pull/1222, with the next upcoming version of the client https://github.com/xataio/client-ts/blob/main/packages/client/CHANGELOG.md#0268 0.26.8 (should be sometime next week), you will be able to use the built-in types. The issue will only occur if you require deeper recursion later on.
As for handling types beyond the supported recursion level there are some helper methods in the SDK, documented here: https://xata.io/docs/sdk/typescript/overview#helper-methods. With
SelectedPick
you can specify the requested fields for the return type, as in the example there.Xata SDK for TypeScript and JavaScript
Use the SDK as a schema-based, schema-less, or an API client