Actually I have found the solution. It is pretty easy. You have to use grpc’s method to create the metadata. And use it on each call. e.g:
This is very similar to GitHub - dgraph-io/dgo: Official Dgraph Go client
Set this “globally”.
var meta = new grpc.Metadata();
meta.add('auth-token', 'myTestSecret');
And on each call add the meta var
async function dropAll(dgraphClient) {
const op = new dgraph.Operation();
op.setDropAll(true);
await dgraphClient.alter(op, meta);
}
async function setSchema(dgraphClient) {
const schema = `
name: string @index(exact) .
age: int .
married: bool .
loc: geo .
dob: datetime .
friend: [uid] @reverse .
`;
const op = new dgraph.Operation();
op.setSchema(schema);
await dgraphClient.alter(op, meta);
}