graphlit-client 1.0.20240418006 → 1.0.20240418007
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +1 -1
- package/dist/client.js +7 -7
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ApolloClient, NormalizedCacheObject } from '@apollo/client';
|
1
|
+
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
2
2
|
import * as Types from './generated/graphql-types';
|
3
3
|
declare class Graphlit {
|
4
4
|
client: ApolloClient<NormalizedCacheObject>;
|
package/dist/client.js
CHANGED
@@ -33,7 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
33
33
|
};
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
35
|
exports.Types = exports.Graphlit = void 0;
|
36
|
-
const
|
36
|
+
const core_1 = require("@apollo/client/core");
|
37
37
|
const Documents = __importStar(require("./generated/graphql-documents"));
|
38
38
|
const jwt = __importStar(require("jsonwebtoken"));
|
39
39
|
const dotenv = __importStar(require("dotenv"));
|
@@ -62,10 +62,10 @@ class Graphlit {
|
|
62
62
|
throw new Error("JWT secret is required.");
|
63
63
|
}
|
64
64
|
this.token = jwt.sign(payload, this.jwtSecret, { algorithm: 'HS256' });
|
65
|
-
const httpLink = (0,
|
65
|
+
const httpLink = (0, core_1.createHttpLink)({
|
66
66
|
uri: this.apiUri,
|
67
67
|
});
|
68
|
-
const authLink = new
|
68
|
+
const authLink = new core_1.ApolloLink((operation, forward) => {
|
69
69
|
operation.setContext({
|
70
70
|
headers: {
|
71
71
|
Authorization: this.token ? `Bearer ${this.token}` : "",
|
@@ -73,9 +73,9 @@ class Graphlit {
|
|
73
73
|
});
|
74
74
|
return forward(operation);
|
75
75
|
});
|
76
|
-
this.client = new
|
76
|
+
this.client = new core_1.ApolloClient({
|
77
77
|
link: authLink.concat(httpLink),
|
78
|
-
cache: new
|
78
|
+
cache: new core_1.InMemoryCache(),
|
79
79
|
});
|
80
80
|
}
|
81
81
|
createAlert(alert) {
|
@@ -392,7 +392,7 @@ class Graphlit {
|
|
392
392
|
return result.data;
|
393
393
|
}
|
394
394
|
catch (error) {
|
395
|
-
if (error instanceof
|
395
|
+
if (error instanceof core_1.ApolloError && error.graphQLErrors.length > 0) {
|
396
396
|
const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
|
397
397
|
throw new Error(errorMessage);
|
398
398
|
}
|
@@ -415,7 +415,7 @@ class Graphlit {
|
|
415
415
|
return result.data;
|
416
416
|
}
|
417
417
|
catch (error) {
|
418
|
-
if (error instanceof
|
418
|
+
if (error instanceof core_1.ApolloError && error.graphQLErrors.length > 0) {
|
419
419
|
const errorMessage = error.graphQLErrors.map(err => err.message).join("\n");
|
420
420
|
throw new Error(errorMessage);
|
421
421
|
}
|