Skip to content

Commit c264bca

Browse files
committed
Fix grpc calls for comapatibility with grpc v1.9
1 parent aec0f32 commit c264bca

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

lib/clientStub.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ var DgraphClientStub = (function () {
2222
};
2323
}
2424
DgraphClientStub.prototype.alter = function (op, options) {
25-
return this.promisified.alter(op, undefined, options);
25+
return this.promisified.alter(op, new grpc.Metadata(), ensureCallOptions(options));
2626
};
2727
DgraphClientStub.prototype.query = function (req, options) {
28-
return this.promisified.query(req, undefined, options);
28+
return this.promisified.query(req, new grpc.Metadata(), ensureCallOptions(options));
2929
};
3030
DgraphClientStub.prototype.mutate = function (mu, options) {
31-
return this.promisified.mutate(mu, undefined, options);
31+
return this.promisified.mutate(mu, new grpc.Metadata(), ensureCallOptions(options));
3232
};
3333
DgraphClientStub.prototype.commitOrAbort = function (ctx, options) {
34-
return this.promisified.commitOrAbort(ctx, undefined, options);
34+
return this.promisified.commitOrAbort(ctx, new grpc.Metadata(), ensureCallOptions(options));
3535
};
3636
DgraphClientStub.prototype.checkVersion = function (check, options) {
37-
return this.promisified.checkVersion(check, undefined, options);
37+
return this.promisified.checkVersion(check, new grpc.Metadata(), ensureCallOptions(options));
3838
};
3939
DgraphClientStub.prototype.waitForReady = function (deadline) {
4040
return this.promisified.waitForReady(deadline);
@@ -48,3 +48,12 @@ var DgraphClientStub = (function () {
4848
return DgraphClientStub;
4949
}());
5050
exports.DgraphClientStub = DgraphClientStub;
51+
function ensureCallOptions(options) {
52+
if (options != null) {
53+
return options;
54+
}
55+
return {
56+
propagate_flags: grpc.propagate.DEFAULTS,
57+
credentials: null,
58+
};
59+
}

src/clientStub.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ export class DgraphClientStub {
6666
}
6767

6868
public alter(op: messages.Operation, options?: grpc.CallOptions | null): Promise<messages.Payload> {
69-
return this.promisified.alter(op, undefined, options);
69+
return this.promisified.alter(op, new grpc.Metadata(), ensureCallOptions(options));
7070
}
7171

7272
public query(req: messages.Request, options?: grpc.CallOptions | null): Promise<messages.Response> {
73-
return this.promisified.query(req, undefined, options);
73+
return this.promisified.query(req, new grpc.Metadata(), ensureCallOptions(options));
7474
}
7575

7676
public mutate(mu: messages.Mutation, options?: grpc.CallOptions | null): Promise<messages.Assigned> {
77-
return this.promisified.mutate(mu, undefined, options);
77+
return this.promisified.mutate(mu, new grpc.Metadata(), ensureCallOptions(options));
7878
}
7979

8080
public commitOrAbort(ctx: messages.TxnContext, options?: grpc.CallOptions | null): Promise<messages.TxnContext> {
81-
return this.promisified.commitOrAbort(ctx, undefined, options);
81+
return this.promisified.commitOrAbort(ctx, new grpc.Metadata(), ensureCallOptions(options));
8282
}
8383

8484
public checkVersion(check: messages.Check, options?: grpc.CallOptions | null): Promise<messages.Version> {
85-
return this.promisified.checkVersion(check, undefined, options);
85+
return this.promisified.checkVersion(check, new grpc.Metadata(), ensureCallOptions(options));
8686
}
8787

8888
public waitForReady(deadline: grpc.Deadline): Promise<void> {
@@ -97,3 +97,14 @@ export class DgraphClientStub {
9797
return this.stub;
9898
}
9999
}
100+
101+
function ensureCallOptions(options?: grpc.CallOptions | null): grpc.CallOptions {
102+
if (options != null) {
103+
return options;
104+
}
105+
106+
return {
107+
propagate_flags: grpc.propagate.DEFAULTS,
108+
credentials: null,
109+
};
110+
}

0 commit comments

Comments
 (0)