TypeError: Cannot read property "serializeBinary" of undefined

Moved from GitHub dgraph-js/83

Posted by scroobius-pip:

dgraph-js: 2.0.1
grpc: 1.24.0
dgraph: 1.1.0

Coded using the 1.X.Y dgraph-js library with dgraph 1.0.1 , then i update the library and database to the latest versions and get the following error:
“TypeError: Cannot read property ‘serializeBinary’ of undefined”

here’s the offending code that worked perfectly on previous version but not this latest version:

import dgraph = require('dgraph-js')
import { data, schema } from './seed'

export default async (client: dgraph.DgraphClient) => {
    try {
        // set schema
        const op = new dgraph.Operation()
        await client.alter(op)

        // set mock data
        const transaction = client.newTxn()
        try {

            const mutation = new dgraph.Mutation()

            await transaction.mutate(mutation)
            await transaction.commit()

        } finally {

    } catch (error) {
        throw new Error(error)

here’s how i’m initializing the client:

const initDgraphClient = (address: string) => {
  try {
    const clientStub = new dgraph.DgraphClientStub(address,
    const client = new dgraph.DgraphClient(clientStub)
    return client
  } catch (error) {
    throw error

prashant-shahi commented :

Thanks, @scroobius-pip for raising this issue. It happens when you fail to create a dgraphClient, usually because of invalid gRPC address or invalid ACL login credentials.

This issue has been resolved with this PR #77. ~We will be releasing the v2.0.2 soon.~

We have released v2.0.2.