weaviate / typescript-client

Official Weaviate TypeScript Client
https://www.npmjs.com/package/weaviate-client
BSD 3-Clause "New" or "Revised" License
57 stars 21 forks source link

weaviate-ts-client library error on sveltekit #86

Closed emilaleksanteri closed 10 months ago

emilaleksanteri commented 11 months ago

Hi, I keep getting this error in the weavite-ts-client source:

"Uncaught (in promise) SyntaxError: missing name after . operator"

The view source points out to the line below FIX ME comment as the issue at weaviate-ts-client.js:2365:35

// node_modules/.pnpm/graphql@16.7.1/node_modules/graphql/jsutils/instanceOf.mjs var instanceOf = ( /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 globalThis.process && globalThis."development" === "production" ? function instanceOf2(value, constructor) { return value instanceof constructor; } : function instanceOf3(value, constructor) { if (value instanceof constructor) { return true; } ...

I don't know if this is an issue in my end on the specific TS config in Sveltekit or if its in the source for certain since the library seems to work on just a vanilla ts-node set up while failing to work in the sveltekit environment.

tsmith023 commented 10 months ago

Hi @emilaleksanteri, this looks like a weird one! Thank you for raising it 😁

Through doing some digging, I've come across this thread: https://github.com/mswjs/msw/issues/1655, where they discuss how graphql@16.7.0 introduces a bug that is relevant to the source that you posted. Their solution is to pin their graphql dependency to below 16.7.0.

I think the same problem that happened there is also affecting us. Our graphql dependency comes through graphql-request, which we depend on as ^5.1.0 thereby installing 5.2.0 in our released npm package. graphql-request@5.2.0 depends on graphql as ^16.6.0 and so itself installs 16.7.1 in our released npm package. You then see erroring source code relevant to the graphql@16.7.1 package in your node_modules folder.

We are in the process of releasing a new version of the TS client that is compatible with the most up-to-date Weaviate server that went live yesterday. I will ensure that this fix is included in that release!

emilaleksanteri commented 10 months ago

@tsmith023 Thank you for the response, sounds exciting!!

tsmith023 commented 10 months ago

@emilaleksanteri, it turns out graphql have actually resolved this already: https://github.com/graphql/graphql-js/pull/3923, so no changes need to be made on our side to deal with the breaking upstream problem. You just need to reinstall your dependencies by deleting node_modules and running npm install --force. Then graphql@16.8.0 should be installed.

I will close this now as not planned since the upstream problem has in fact been addressed

😁