When upgrading to the latest version of dgraph-js (v20.3.1), I’m getting the following error:
TypeError: Channel credentials must be a ChannelCredentials object
at new ChannelImplementation (/Users/akari/cute-git/dtest/node_modules/@grpc/grpc-js/build/src/channel.js:69:19)
at new Client (/Users/akari/cute-git/dtest/node_modules/@grpc/grpc-js/build/src/client.js:58:36)
at new ServiceClientImpl (/Users/akari/cute-git/dtest/node_modules/@grpc/grpc-js/build/src/make-client.js:50:5)
at new DgraphClientStub (/Users/akari/cute-git/dtest/node_modules/dgraph-js/lib/clientStub.js:55:21)
at Object.<anonymous> (/Users/akari/cute-git/dtest/test.js:4:20)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
I made a new test project with the following js:
const dgraph = require("dgraph-js")
const grpc = require("grpc")
const clientStub = new dgraph.DgraphClientStub(
"localhost:9080",
grpc.credentials.createInsecure()
)
const dgraphClient = new dgraph.DgraphClient(clientStub)
async function test() {
const op = new dgraph.Operation()
op.setSchema(`
type Abc {
cats
}
cats: float .
`)
op.setRunInBackground(true)
await dgraphClient.alter(op)
}
test()
The package.json is as follows:
{
"name": "dtest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dgraph-js": "^20.3.1",
"grpc": "^1.24.3"
}
}
The previous version (v20.3.0) works without any issues.