graphlit-client 1.0.20240418022 → 1.0.20240418023
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.js +26 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
@@ -89,6 +89,19 @@ class Graphlit {
|
|
89
89
|
this.client = new core_1.ApolloClient({
|
90
90
|
link: authLink.concat(httpLink),
|
91
91
|
cache: new core_1.InMemoryCache(),
|
92
|
+
defaultOptions: {
|
93
|
+
watchQuery: {
|
94
|
+
fetchPolicy: 'cache-and-network',
|
95
|
+
errorPolicy: 'ignore',
|
96
|
+
},
|
97
|
+
query: {
|
98
|
+
fetchPolicy: 'network-only',
|
99
|
+
errorPolicy: 'all',
|
100
|
+
},
|
101
|
+
mutate: {
|
102
|
+
errorPolicy: 'all',
|
103
|
+
}
|
104
|
+
}
|
92
105
|
});
|
93
106
|
}
|
94
107
|
createAlert(alert) {
|
@@ -401,6 +414,10 @@ class Graphlit {
|
|
401
414
|
mutation,
|
402
415
|
variables: variables || {}
|
403
416
|
});
|
417
|
+
if (result.errors) {
|
418
|
+
const errorMessage = result.errors.map(err => err.message).join("\n");
|
419
|
+
throw new Error(errorMessage);
|
420
|
+
}
|
404
421
|
if (!result.data) {
|
405
422
|
throw new Error('No data returned from mutation.');
|
406
423
|
}
|
@@ -419,6 +436,7 @@ class Graphlit {
|
|
419
436
|
}
|
420
437
|
queryAndCheckError(query, variables) {
|
421
438
|
return __awaiter(this, void 0, void 0, function* () {
|
439
|
+
var _a, _b;
|
422
440
|
if (this.client === undefined)
|
423
441
|
throw new Error("Apollo Client not configured.");
|
424
442
|
try {
|
@@ -426,6 +444,14 @@ class Graphlit {
|
|
426
444
|
query,
|
427
445
|
variables: variables || {}
|
428
446
|
});
|
447
|
+
if ((_a = result.error) === null || _a === void 0 ? void 0 : _a.graphQLErrors) {
|
448
|
+
const errorMessage = result.error.graphQLErrors.map(err => err.message).join("\n");
|
449
|
+
throw new Error(errorMessage);
|
450
|
+
}
|
451
|
+
if ((_b = result.error) === null || _b === void 0 ? void 0 : _b.clientErrors) {
|
452
|
+
const errorMessage = result.error.clientErrors.map(err => err.message).join("\n");
|
453
|
+
throw new Error(errorMessage);
|
454
|
+
}
|
429
455
|
if (!result.data) {
|
430
456
|
throw new Error('No data returned from query');
|
431
457
|
}
|