Problems setting up Drizzle ORM with HTTP client via client/cli@ne
Hi, I'm having some trouble setting up the drizzle ORM with http client.
In particular following https://xata.io/docs/integrations/drizzle, I'm running
yarn add @xata.io/client@next
and I also have the following version of the cli installed:
@xata.io/cli/0.0.0-next.v64f10283eb9a098c575590d3ea17600e350321c9
However, when I run xata init
, one of the steps is overwriting the xata client version in package.json to
"@xata.io/client": "^0.30.0",
Then the generated xata.ts
has an error:
This error gets fixed if then I reinstall the next version of the xata client, however the generated xata.ts
file also doesn't export (or even define) getXataClient
, which is required by the setup in the guide https://xata.io/docs/integrations/drizzle, ie. it says:
Any help getting xata to work with Drizzle orm would be much appreciated.11 Replies
hi, thanks for reporting, I think you might have hit a bug mixing
@next
and @latest
installations of the CLI and SDK. We're able to reproduce it and we're working on a fix.
In the meantime, could you try the following workaround:
* manually edit the package.json
and remove the xata
dependency. Also remove references to the xata generated files.
* double-check that the xata CLI version is cli@next
* run xata init
again
This should hopefully result in having the @next
version of the SDK installed and a correctly generated xata.ts
Hi @tsg thanks very much for your quick response!
I followed your steps and this does result in having the correctly installed
@next
sdk, and the generated xata.ts
now has no import errors.
However the generated xata.ts
still doesn't define getXataClient
...
Do you have a suggested workaround for this?yeah,
getXataClient
doesn't do that much actually. You can instantiate it directly like this:
There is an example of doing this here: https://xata.io/docs/sdk/typescript/overview#configurationTypeScript SDK for Xata
Use the SDK as a schema-based, schema-less, or an API client
@tsg great - that’s what I resorted to, thanks very much for the clarification!
great, I'll ping you back when the proper fix is in place.
Hi @tsg just wondering if there has been any progress with this (or eg do you have a github issue that I can watch) ? We just switched to using pnpm in our monorepo and the issue has come back. We are currently stuck until this is fixed...
Our package.json looks like this:
Checking with the team, I thought it would be fixed
@tsg basically, even with the
@xata/io/client@next
version in the package.json, we're still getting errors of the form ts: '"@xata.io/client"' has no exported member named 'getDeployPreviewBranch'. Did you mean 'getPreviewBranch'?
in xata.ts
so if you repeat the steps above you still get the broken xata.ts?
I was trying it now with the latest, which is:
And seemed to work.
Basically what I did:
The xata.ts seems to compile fine.
@tsg thanks for the confirmation - it seems that the generated xata.ts was pointing to a previous (next) version of the @Xata.io/client. So when I followed your instructions (in addition to clearing out the node_modules) the type error has gone away. thanks again for your help! 👍
ah good, thanks for the update! Let us know if it shows up again