Skip to content

TypeError: Cannot read property "serializeBinary" of undefined #83

@scroobius-pip

Description

@scroobius-pip

versions:
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()
        op.setSchema(schema)
        await client.alter(op)

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

            const mutation = new dgraph.Mutation()

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

        } finally {
            transaction.discard()
        }

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

here's how i'm initializing the client:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions