Skip to content

Commit 46b079c

Browse files
Merge pull request #138 from dgraph-io/apoorv/fix-deprecation
fix(deprecation): add clientStubFromCloudEndpoint method
2 parents 83621ba + 73b14e9 commit 46b079c

File tree

12 files changed

+40
-50
lines changed

12 files changed

+40
-50
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ If you want to connect to Dgraph running on your [Dgraph Cloud](https://cloud.dg
128128
```js
129129
const dgraph = require("dgraph-js");
130130

131-
const clientStub = dgraph.clientStubFromSlashGraphQLEndpoint(
131+
const clientStub = dgraph.clientStubFromCloudEndpoint(
132132
"https://frozen-mango.eu-central-1.aws.cloud.dgraph.io/graphql",
133133
"<api-key>"
134134
);
135135
const dgraphClient = new dgraph.DgraphClient(clientStub);
136136
```
137137

138-
**Note:** the `clientStubFromSlashGraphQLEndpoint` method is deprecated and will be removed in the next release.
138+
**Note:** the `clientStubFromSlashGraphQLEndpoint` method is deprecated and will be removed in the next release. Instead use `clientStubFromCloudEndpoint` method.
139139

140140
### Altering the Database
141141

@@ -499,4 +499,3 @@ Make sure you have a Dgraph server running on localhost before you run this task
499499
```sh
500500
npm test
501501
```
502-

lib/client.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
3636
}
3737
};
3838
Object.defineProperty(exports, "__esModule", { value: true });
39-
exports.deleteEdges = exports.isJwtExpired = exports.DgraphClient = void 0;
4039
var messages = require("../generated/api_pb");
4140
var errors_1 = require("./errors");
4241
var txn_1 = require("./txn");

lib/clientStub.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
3636
}
3737
};
3838
Object.defineProperty(exports, "__esModule", { value: true });
39-
exports.DgraphClientStub = void 0;
4039
var grpc = require("@grpc/grpc-js");
4140
var services = require("../generated/api_grpc_pb");
4241
var messages = require("../generated/api_pb");

lib/clientStubFromSlash.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import { DgraphClientStub } from "./clientStub";
22
export declare function clientStubFromSlashGraphQLEndpoint(graphqlEndpoint: string, apiKey: string): DgraphClientStub;
3+
export declare function clientStubFromCloudEndpoint(graphqlEndpoint: string, apiKey: string): DgraphClientStub;

lib/clientStubFromSlash.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.clientStubFromSlashGraphQLEndpoint = void 0;
43
var grpc = require("@grpc/grpc-js");
54
var Url = require("url-parse");
65
var clientStub_1 = require("./clientStub");
76
var PORT = "443";
87
function clientStubFromSlashGraphQLEndpoint(graphqlEndpoint, apiKey) {
8+
return clientStubFromCloudEndpoint(graphqlEndpoint, apiKey);
9+
}
10+
exports.clientStubFromSlashGraphQLEndpoint = clientStubFromSlashGraphQLEndpoint;
11+
function clientStubFromCloudEndpoint(graphqlEndpoint, apiKey) {
912
var url = new Url(graphqlEndpoint);
1013
var urlParts = url.host.split(".");
1114
var firstHalf = urlParts[0];
@@ -19,4 +22,4 @@ function clientStubFromSlashGraphQLEndpoint(graphqlEndpoint, apiKey) {
1922
var credentials = grpc.credentials.combineChannelCredentials(grpc.credentials.createSsl(), metaCreds);
2023
return new clientStub_1.DgraphClientStub(backenedURL, credentials);
2124
}
22-
exports.clientStubFromSlashGraphQLEndpoint = clientStubFromSlashGraphQLEndpoint;
25+
exports.clientStubFromCloudEndpoint = clientStubFromCloudEndpoint;

lib/dgraph.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
"use strict";
2-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3-
if (k2 === undefined) k2 = k;
4-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5-
}) : (function(o, m, k, k2) {
6-
if (k2 === undefined) k2 = k;
7-
o[k2] = m[k];
8-
}));
9-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
10-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11-
};
2+
function __export(m) {
3+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4+
}
125
Object.defineProperty(exports, "__esModule", { value: true });
13-
__exportStar(require("./types"), exports);
6+
__export(require("./types"));
147
var api_pb_1 = require("../generated/api_pb");
15-
Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return api_pb_1.Operation; } });
16-
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return api_pb_1.Request; } });
17-
Object.defineProperty(exports, "TxnContext", { enumerable: true, get: function () { return api_pb_1.TxnContext; } });
18-
Object.defineProperty(exports, "Check", { enumerable: true, get: function () { return api_pb_1.Check; } });
19-
Object.defineProperty(exports, "Version", { enumerable: true, get: function () { return api_pb_1.Version; } });
20-
Object.defineProperty(exports, "NQuad", { enumerable: true, get: function () { return api_pb_1.NQuad; } });
21-
Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return api_pb_1.Value; } });
22-
Object.defineProperty(exports, "Facet", { enumerable: true, get: function () { return api_pb_1.Facet; } });
23-
Object.defineProperty(exports, "Latency", { enumerable: true, get: function () { return api_pb_1.Latency; } });
24-
__exportStar(require("./clientStub"), exports);
25-
__exportStar(require("./client"), exports);
26-
__exportStar(require("./clientStubFromSlash"), exports);
27-
__exportStar(require("./txn"), exports);
28-
__exportStar(require("./errors"), exports);
8+
exports.Operation = api_pb_1.Operation;
9+
exports.Request = api_pb_1.Request;
10+
exports.TxnContext = api_pb_1.TxnContext;
11+
exports.Check = api_pb_1.Check;
12+
exports.Version = api_pb_1.Version;
13+
exports.NQuad = api_pb_1.NQuad;
14+
exports.Value = api_pb_1.Value;
15+
exports.Facet = api_pb_1.Facet;
16+
exports.Latency = api_pb_1.Latency;
17+
__export(require("./clientStub"));
18+
__export(require("./client"));
19+
__export(require("./clientStubFromSlash"));
20+
__export(require("./txn"));
21+
__export(require("./errors"));
2922
exports.grpc = require("@grpc/grpc-js");

lib/errors.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.ERR_REFRESH_JWT_EMPTY = exports.ERR_READ_ONLY = exports.ERR_BEST_EFFORT_REQUIRED_READ_ONLY = exports.ERR_ABORTED = exports.ERR_FINISHED = exports.ERR_NO_CLIENTS = void 0;
43
exports.ERR_NO_CLIENTS = new Error("No clients provided in DgraphClient constructor");
54
exports.ERR_FINISHED = new Error("Transaction has already been committed or discarded");
65
exports.ERR_ABORTED = new Error("Transaction has been aborted. Please retry");

lib/index.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
"use strict";
2-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3-
if (k2 === undefined) k2 = k;
4-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5-
}) : (function(o, m, k, k2) {
6-
if (k2 === undefined) k2 = k;
7-
o[k2] = m[k];
8-
}));
9-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
10-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11-
};
2+
function __export(m) {
3+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4+
}
125
Object.defineProperty(exports, "__esModule", { value: true });
136
var dgraph = require("./dgraph");
14-
__exportStar(require("./dgraph"), exports);
7+
__export(require("./dgraph"));
158
exports.default = dgraph;

lib/txn.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
4747
}
4848
};
4949
Object.defineProperty(exports, "__esModule", { value: true });
50-
exports.Txn = void 0;
5150
var messages = require("../generated/api_pb");
5251
var client_1 = require("./client");
5352
var errors_1 = require("./errors");

lib/types.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var __extends = (this && this.__extends) || (function () {
1313
};
1414
})();
1515
Object.defineProperty(exports, "__esModule", { value: true });
16-
exports.Mutation = exports.createResponse = exports.Response = exports.createPayload = exports.Payload = void 0;
1716
var jspb = require("google-protobuf");
1817
var messages = require("../generated/api_pb");
1918
var util_1 = require("./util");

lib/util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.strToJson = exports.u8ToStr = exports.b64ToStr = exports.strToU8 = exports.strToB64 = exports.stringifyMessage = exports.promisify3 = exports.promisify1 = exports.isUnauthenticatedError = exports.isConflictError = exports.isAbortedError = exports.errorCode = void 0;
43
var grpc = require("@grpc/grpc-js");
54
function errorCode(err) {
65
if (err === undefined ||
@@ -64,7 +63,7 @@ function stringifyMessage(msg) {
6463
}
6564
exports.stringifyMessage = stringifyMessage;
6665
var is_base64_1 = require("is-base64");
67-
Object.defineProperty(exports, "isBase64", { enumerable: true, get: function () { return is_base64_1.isBase64; } });
66+
exports.isBase64 = is_base64_1.isBase64;
6867
function strToB64(str) {
6968
return Buffer.from(str, "utf8").toString("base64");
7069
}

src/clientStubFromSlash.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ import { DgraphClientStub } from "./clientStub";
44

55
const PORT = "443";
66
/**
7-
* @deprecated since v21.3 and will be removed in v21.07 release. For more details, see:
8-
* https://discuss.dgraph.io/t/regarding-slash-cloud-dgraph-endpoints-in-the-clients/13492
7+
* @deprecated since v21.3 and will be removed in v21.07 release.
8+
* Please use {@link clientStubFromCloudEndpoint} instead.
99
*/
1010

1111
export function clientStubFromSlashGraphQLEndpoint(
1212
graphqlEndpoint: string,
1313
apiKey: string,
14+
) {
15+
return clientStubFromCloudEndpoint(graphqlEndpoint, apiKey);
16+
}
17+
18+
export function clientStubFromCloudEndpoint(
19+
graphqlEndpoint: string,
20+
apiKey: string,
1421
) {
1522
const url = new Url(graphqlEndpoint);
1623
const urlParts = url.host.split(".");

0 commit comments

Comments
 (0)