weaviate / typescript-client

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

Is graphql dependency missing from 3.0.0-beta? #119

Closed mikhailshilkov closed 3 months ago

mikhailshilkov commented 3 months ago

I've setup a basic TypeScript project using 3.0.0-beta.20 but it fails to compile with

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'graphql' imported from /Users/mikhailshilkov/go/src/github.com/pulumi/play/weaviate/node_modules/graphql-request/build/esm/resolveRequestDocument.js

Adding an explicit reference to graphql fixes the problem.

My package.json:

{
  "name": "weaviate-ts-example",
  "version": "1.0.0",
  "description": "",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "type": "module",
  "dependencies": {
    "weaviate-client": "^3.0.0-beta.20"
  },
  "scripts": {
    "start": "tsc && node dist/index.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": "^4.9.5"
  }
}

My tsconfig.json:

{
    "compilerOptions": {
      "target": "es2020",
      "strict": true,
      "preserveConstEnums": true,
      "noEmit": false,
      "sourceMap": false,
      "module":"ES2022",
      "moduleResolution":"node",
      "esModuleInterop": true,
      "skipLibCheck": true,
      "forceConsistentCasingInFileNames": true,
      "isolatedModules": true,
      "outDir": "./dist"
    },
    "include": ["**/*"],
    "exclude": ["node_modules"]
  }

My index.ts:

import weaviate, { WeaviateClient } from 'weaviate-client';

const client: WeaviateClient = await weaviate.connectToWCS(
  'redacted', {
   authCredentials: new weaviate.ApiKey('redacted'),
 } 
);

const response = await client.isReady();
console.log(response);

I'm using yarn.

tsmith023 commented 3 months ago

Hi Mikhail, you're quite right that this dependency is missing, thanks for calling it out!

I'll make sure that it is fixed in the next beta release 😁

tsmith023 commented 3 months ago

Have released v3.0.0-beta.21 with this fix!