graphql-persisted 0.0.1 → 0.0.3
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/cjs/GraphQLQueryCache.js +46 -59
- package/cjs/fragmentData.d.ts +1 -0
- package/cjs/fragmentData.js +1 -0
- package/cjs/graphqlHooks.d.ts +6 -6
- package/cjs/graphqlHooks.js +13 -13
- package/mjs/GraphQLQueryCache.js +1 -11
- package/mjs/fragmentData.d.ts +1 -0
- package/mjs/fragmentData.js +1 -0
- package/mjs/graphqlHooks.d.ts +6 -6
- package/mjs/graphqlHooks.js +12 -12
- package/package.json +3 -2
package/cjs/GraphQLQueryCache.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
2
|
var _GraphQLQueryCache_instances, _GraphQLQueryCache_fetcher, _GraphQLQueryCache_endpoint, _GraphQLQueryCache_persistedOperations, _GraphQLQueryCache_persistedDocuments, _GraphQLQueryCache_configMeta, _GraphQLQueryCache_subscribedQueries, _GraphQLQueryCache_inFlight, _GraphQLQueryCache_cacheStore, _GraphQLQueryCache_runtimeCache, _GraphQLQueryCache_queryInvalidation, _GraphQLQueryCache_mutationInvalidation, _GraphQLQueryCache_effectsIssued, _GraphQLQueryCache_getKey, _GraphQLQueryCache_executeOperation, _GraphQLQueryCache_getMeta, _GraphQLQueryCache_fetch, _GraphQLQueryCache_shouldRefetchQuery, _GraphQLQueryCache_gcOperations;
|
|
17
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
4
|
exports.GraphQLQueryCache = void 0;
|
|
19
|
-
const
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const lodash_isequal_1 = tslib_1.__importDefault(require("lodash.isequal"));
|
|
20
7
|
const graphql_normalize_1 = require("graphql-normalize");
|
|
21
8
|
const immer_1 = require("immer");
|
|
22
9
|
const errors_1 = require("./errors");
|
|
@@ -70,14 +57,14 @@ class GraphQLQueryCache {
|
|
|
70
57
|
* A list of all "effects" that have run, used to keep track of
|
|
71
58
|
*/
|
|
72
59
|
_GraphQLQueryCache_effectsIssued.set(this, []); // TODO: Include subscriptions
|
|
73
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_fetcher, config.fetcher || fetch, "f");
|
|
74
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_endpoint, config.endpoint || `${window.location.origin}/graphql`, "f");
|
|
75
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_persistedOperations, config.persistedOperations, "f");
|
|
76
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_persistedDocuments, config.persistedDocuments, "f");
|
|
77
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_configMeta, unwrapMeta(config.meta), "f");
|
|
78
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_queryInvalidation, config.queryInvalidation ?? {}, "f");
|
|
79
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_mutationInvalidation, config.mutationInvalidation ?? {}, "f");
|
|
80
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(config.hydratedCache ?? {
|
|
60
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_fetcher, config.fetcher || fetch, "f");
|
|
61
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_endpoint, config.endpoint || `${window.location.origin}/graphql`, "f");
|
|
62
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_persistedOperations, config.persistedOperations, "f");
|
|
63
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_persistedDocuments, config.persistedDocuments, "f");
|
|
64
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_configMeta, unwrapMeta(config.meta), "f");
|
|
65
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_queryInvalidation, config.queryInvalidation ?? {}, "f");
|
|
66
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_mutationInvalidation, config.mutationInvalidation ?? {}, "f");
|
|
67
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(config.hydratedCache ?? {
|
|
81
68
|
meta: {},
|
|
82
69
|
fields: {},
|
|
83
70
|
operations: {},
|
|
@@ -87,7 +74,7 @@ class GraphQLQueryCache {
|
|
|
87
74
|
* Invalidates a query by name or predicate fn
|
|
88
75
|
*/
|
|
89
76
|
invalidateQuery(toInvalidate) {
|
|
90
|
-
(0, immer_1.produce)(__classPrivateFieldGet(this, _GraphQLQueryCache_runtimeCache, "f"), () => {
|
|
77
|
+
(0, immer_1.produce)(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_runtimeCache, "f"), () => {
|
|
91
78
|
//
|
|
92
79
|
});
|
|
93
80
|
}
|
|
@@ -95,7 +82,7 @@ class GraphQLQueryCache {
|
|
|
95
82
|
* Invalidates a query by name or predicate fn
|
|
96
83
|
*/
|
|
97
84
|
refetchQuery(toRefetch) {
|
|
98
|
-
(0, immer_1.produce)(__classPrivateFieldGet(this, _GraphQLQueryCache_runtimeCache, "f"), () => {
|
|
85
|
+
(0, immer_1.produce)(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_runtimeCache, "f"), () => {
|
|
99
86
|
//
|
|
100
87
|
});
|
|
101
88
|
}
|
|
@@ -104,7 +91,7 @@ class GraphQLQueryCache {
|
|
|
104
91
|
* to rehydrate the Client
|
|
105
92
|
*/
|
|
106
93
|
toJSON() {
|
|
107
|
-
const { fields, operations, meta } = __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f");
|
|
94
|
+
const { fields, operations, meta } = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f");
|
|
108
95
|
return {
|
|
109
96
|
fields,
|
|
110
97
|
operations: operations,
|
|
@@ -142,19 +129,19 @@ class GraphQLQueryCache {
|
|
|
142
129
|
*/
|
|
143
130
|
readQuery(args) {
|
|
144
131
|
const { queryName, variables, options } = args;
|
|
145
|
-
const key = __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, queryName, variables);
|
|
146
|
-
const op = __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
132
|
+
const key = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, queryName, variables);
|
|
133
|
+
const op = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
147
134
|
if (op) {
|
|
148
135
|
return op;
|
|
149
136
|
}
|
|
150
137
|
// If we don't have metadata, we can't know how to read the query
|
|
151
138
|
// from the cache
|
|
152
|
-
const meta = __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getMeta).call(this, queryName);
|
|
139
|
+
const meta = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getMeta).call(this, queryName);
|
|
153
140
|
const { result } = (0, graphql_normalize_1.graphqlNormalize)({
|
|
154
141
|
action: 'read',
|
|
155
142
|
variableValues: typeof variables === 'string' ? JSON.parse(variables) : variables,
|
|
156
143
|
meta: meta,
|
|
157
|
-
cache: __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").fields,
|
|
144
|
+
cache: tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").fields,
|
|
158
145
|
isEqual: lodash_isequal_1.default,
|
|
159
146
|
});
|
|
160
147
|
return {
|
|
@@ -189,9 +176,9 @@ class GraphQLQueryCache {
|
|
|
189
176
|
preloadQuery(queryName, options) {
|
|
190
177
|
const { blockIfStale = true } = options;
|
|
191
178
|
const variables = (0, helpers_1.variableString)(options.variables ?? {});
|
|
192
|
-
const sha256Hash = __classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[queryName];
|
|
179
|
+
const sha256Hash = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[queryName];
|
|
193
180
|
const key = `${sha256Hash}:${variables}`;
|
|
194
|
-
const operation = __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
181
|
+
const operation = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
195
182
|
// TODO: Give an option to eager return if we already have the operation but it's stale
|
|
196
183
|
if (!operation || operation.stale) {
|
|
197
184
|
const inFlight = this.fetchQuery({ queryName, variables: variables, options: {} });
|
|
@@ -200,19 +187,19 @@ class GraphQLQueryCache {
|
|
|
200
187
|
return operation;
|
|
201
188
|
}
|
|
202
189
|
fetchQuery(args) {
|
|
203
|
-
return __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'query', args.queryName, args.variables, args.options);
|
|
190
|
+
return tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'query', args.queryName, args.variables, args.options);
|
|
204
191
|
}
|
|
205
192
|
/**
|
|
206
193
|
* Executes a mutation, returning the result of that mutation
|
|
207
194
|
*/
|
|
208
195
|
async executeMutation(mutationName, variables, options = {}) {
|
|
209
|
-
return __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'mutation', mutationName, variables, options);
|
|
196
|
+
return tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'mutation', mutationName, variables, options);
|
|
210
197
|
}
|
|
211
198
|
/**
|
|
212
199
|
* Executes a query, returning the result of that query
|
|
213
200
|
*/
|
|
214
201
|
async executeQuery(queryName, variables) {
|
|
215
|
-
return __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'query', queryName, variables);
|
|
202
|
+
return tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_executeOperation).call(this, 'query', queryName, variables);
|
|
216
203
|
}
|
|
217
204
|
async executeSubscription() {
|
|
218
205
|
throw new Error('Not yet supported');
|
|
@@ -225,8 +212,8 @@ class GraphQLQueryCache {
|
|
|
225
212
|
subscribeToQuery(args) {
|
|
226
213
|
var _a;
|
|
227
214
|
const { queryName, queryResult, variables, onUpdate, options } = args;
|
|
228
|
-
const key = __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, queryName, variables);
|
|
229
|
-
const queries = ((_a = __classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f"))[key] ?? (_a[key] = []));
|
|
215
|
+
const key = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, queryName, variables);
|
|
216
|
+
const queries = ((_a = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f"))[key] ?? (_a[key] = []));
|
|
230
217
|
queries.push(args);
|
|
231
218
|
// Now that the component is subscribed, we can begin fetching,
|
|
232
219
|
// refetching, and otherwise managing the query
|
|
@@ -244,18 +231,18 @@ class GraphQLQueryCache {
|
|
|
244
231
|
}
|
|
245
232
|
exports.GraphQLQueryCache = GraphQLQueryCache;
|
|
246
233
|
_GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new WeakMap(), _GraphQLQueryCache_persistedOperations = new WeakMap(), _GraphQLQueryCache_persistedDocuments = new WeakMap(), _GraphQLQueryCache_configMeta = new WeakMap(), _GraphQLQueryCache_subscribedQueries = new WeakMap(), _GraphQLQueryCache_inFlight = new WeakMap(), _GraphQLQueryCache_cacheStore = new WeakMap(), _GraphQLQueryCache_runtimeCache = new WeakMap(), _GraphQLQueryCache_queryInvalidation = new WeakMap(), _GraphQLQueryCache_mutationInvalidation = new WeakMap(), _GraphQLQueryCache_effectsIssued = new WeakMap(), _GraphQLQueryCache_instances = new WeakSet(), _GraphQLQueryCache_getKey = function _GraphQLQueryCache_getKey(operationName, variables) {
|
|
247
|
-
const sha256Hash = __classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[operationName];
|
|
234
|
+
const sha256Hash = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[operationName];
|
|
248
235
|
return `${sha256Hash}:${(0, helpers_1.variableString)(variables)}`;
|
|
249
236
|
}, _GraphQLQueryCache_executeOperation = async function _GraphQLQueryCache_executeOperation(operationType, operationName, variables) {
|
|
250
|
-
const sha256Hash = __classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[operationName];
|
|
251
|
-
const key = __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, operationName, variables);
|
|
237
|
+
const sha256Hash = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_persistedOperations, "f")[operationName];
|
|
238
|
+
const key = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getKey).call(this, operationName, variables);
|
|
252
239
|
const operationVariables = (0, helpers_1.variableObject)(variables);
|
|
253
240
|
(0, errors_1.assertOperationHash)(sha256Hash, operationType, operationName);
|
|
254
|
-
const inFlight = __classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key];
|
|
241
|
+
const inFlight = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key];
|
|
255
242
|
if (operationType === 'query' && inFlight) {
|
|
256
243
|
return inFlight;
|
|
257
244
|
}
|
|
258
|
-
const operationInFlight = __classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_fetch).call(this, {
|
|
245
|
+
const operationInFlight = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_fetch).call(this, {
|
|
259
246
|
query: '',
|
|
260
247
|
operationName,
|
|
261
248
|
variables: operationVariables,
|
|
@@ -263,21 +250,21 @@ _GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new We
|
|
|
263
250
|
persistedQuery: { version: 1, sha256Hash },
|
|
264
251
|
},
|
|
265
252
|
});
|
|
266
|
-
__classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key] = operationInFlight;
|
|
253
|
+
tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key] = operationInFlight;
|
|
267
254
|
const operationResult = await operationInFlight.finally(() => {
|
|
268
|
-
delete __classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key];
|
|
255
|
+
delete tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_inFlight, "f")[key];
|
|
269
256
|
});
|
|
270
257
|
if (operationResult.fetchError) {
|
|
271
258
|
return operationResult;
|
|
272
259
|
}
|
|
273
260
|
const meta = operationResult.extensions?.['graphqlNormalizeMeta'] ??
|
|
274
|
-
__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getMeta).call(this, operationName);
|
|
261
|
+
tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_instances, "m", _GraphQLQueryCache_getMeta).call(this, operationName);
|
|
275
262
|
// Ensure we have metadata to be able to normalize the operation in our cache
|
|
276
263
|
if (!meta) {
|
|
277
264
|
throw new errors_1.MissingMetaError(operationName);
|
|
278
265
|
}
|
|
279
|
-
const lastCache = __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f");
|
|
280
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f"), (c) => {
|
|
266
|
+
const lastCache = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f");
|
|
267
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f"), (c) => {
|
|
281
268
|
const currentResult = c.operations[key];
|
|
282
269
|
const { added, modified, result } = (0, graphql_normalize_1.graphqlNormalize)({
|
|
283
270
|
action: 'write',
|
|
@@ -329,14 +316,14 @@ _GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new We
|
|
|
329
316
|
if (operationType === 'mutation') {
|
|
330
317
|
const toInvalidate = new Set();
|
|
331
318
|
const mutationName = operationName;
|
|
332
|
-
const mutationFn = __classPrivateFieldGet(this, _GraphQLQueryCache_mutationInvalidation, "f")?.[mutationName];
|
|
333
|
-
for (const [operationKey, operation] of Object.entries(__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations)) {
|
|
319
|
+
const mutationFn = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_mutationInvalidation, "f")?.[mutationName];
|
|
320
|
+
for (const [operationKey, operation] of Object.entries(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations)) {
|
|
334
321
|
if (operation.operationType !== 'query') {
|
|
335
322
|
continue;
|
|
336
323
|
}
|
|
337
324
|
const queryName = operation.operationName;
|
|
338
325
|
const queryVariables = operation.variableValues;
|
|
339
|
-
const queryFn = __classPrivateFieldGet(this, _GraphQLQueryCache_queryInvalidation, "f")[queryName];
|
|
326
|
+
const queryFn = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_queryInvalidation, "f")[queryName];
|
|
340
327
|
if (queryFn?.(mutationName, operationVariables, queryVariables)) {
|
|
341
328
|
toInvalidate.add(operationKey);
|
|
342
329
|
}
|
|
@@ -345,7 +332,7 @@ _GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new We
|
|
|
345
332
|
}
|
|
346
333
|
}
|
|
347
334
|
if (toInvalidate.size) {
|
|
348
|
-
__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f"), (o) => {
|
|
335
|
+
tslib_1.__classPrivateFieldSet(this, _GraphQLQueryCache_cacheStore, (0, immer_1.produce)(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f"), (o) => {
|
|
349
336
|
for (const key of toInvalidate) {
|
|
350
337
|
const op = o.operations[key];
|
|
351
338
|
if (op)
|
|
@@ -355,21 +342,21 @@ _GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new We
|
|
|
355
342
|
}
|
|
356
343
|
}
|
|
357
344
|
// If we've updated any operations, we need to update any subscribed components
|
|
358
|
-
if (lastCache.operations !== __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations) {
|
|
359
|
-
for (const [key, val] of Object.entries(__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations)) {
|
|
360
|
-
if (__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key] !== lastCache.operations[key]) {
|
|
361
|
-
if (__classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f")[key]) {
|
|
362
|
-
__classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f")[key]?.forEach((o) => o.onUpdate(val));
|
|
345
|
+
if (lastCache.operations !== tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations) {
|
|
346
|
+
for (const [key, val] of Object.entries(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations)) {
|
|
347
|
+
if (tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key] !== lastCache.operations[key]) {
|
|
348
|
+
if (tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f")[key]) {
|
|
349
|
+
tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_subscribedQueries, "f")[key]?.forEach((o) => o.onUpdate(val));
|
|
363
350
|
}
|
|
364
351
|
}
|
|
365
352
|
}
|
|
366
353
|
}
|
|
367
354
|
if (operationType === 'query') {
|
|
368
|
-
return __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
355
|
+
return tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").operations[key];
|
|
369
356
|
}
|
|
370
357
|
return operationResult;
|
|
371
358
|
}, _GraphQLQueryCache_getMeta = function _GraphQLQueryCache_getMeta(opName) {
|
|
372
|
-
const meta = __classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").meta[opName] ?? __classPrivateFieldGet(this, _GraphQLQueryCache_configMeta, "f")?.[opName];
|
|
359
|
+
const meta = tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_cacheStore, "f").meta[opName] ?? tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_configMeta, "f")?.[opName];
|
|
373
360
|
if (!meta) {
|
|
374
361
|
throw new errors_1.MissingMetaError(opName);
|
|
375
362
|
}
|
|
@@ -382,7 +369,7 @@ _GraphQLQueryCache_fetcher = new WeakMap(), _GraphQLQueryCache_endpoint = new We
|
|
|
382
369
|
async function _GraphQLQueryCache_fetch(body) {
|
|
383
370
|
let result;
|
|
384
371
|
try {
|
|
385
|
-
result = await fetch(__classPrivateFieldGet(this, _GraphQLQueryCache_endpoint, "f"), {
|
|
372
|
+
result = await fetch(tslib_1.__classPrivateFieldGet(this, _GraphQLQueryCache_endpoint, "f"), {
|
|
386
373
|
method: 'POST',
|
|
387
374
|
body: JSON.stringify(body),
|
|
388
375
|
headers: {
|
package/cjs/fragmentData.d.ts
CHANGED
package/cjs/fragmentData.js
CHANGED
package/cjs/graphqlHooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { GraphQLPreloadedQueryResult, GraphQLQueryLazyResult, GraphQLQueryR
|
|
|
6
6
|
* This hook keeps track of the value of the last render, so we're always guaranteed
|
|
7
7
|
* to have data here, even if it's potentially stale.
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare function usePreloadedPersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(query: QueryName, options: PersistedQueryOptions & QueryVariables<QueryName>): GraphQLPreloadedQueryResult<QueryName>;
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the persisted query from the cache,
|
|
12
12
|
* creating it from the cache if we don't have a mounted version
|
|
@@ -18,31 +18,31 @@ export declare const usePreloadedPersistedQuery: <QueryName extends never>(query
|
|
|
18
18
|
* a) The TTL setting
|
|
19
19
|
* b) A mutation which invalidates the query
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare function usePersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(queryName: QueryName, options: PersistedQueryOptions & QueryVariables<QueryName>): GraphQLQueryResult<QueryName>;
|
|
22
22
|
/**
|
|
23
23
|
* TODO: Not working yet
|
|
24
24
|
* Creates a container for a query that isn't fetched immediately,
|
|
25
25
|
* but provides a loadQuery function to call
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare function useLazyPersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(query: QueryName): GraphQLQueryLazyResult<QueryName>;
|
|
28
28
|
/**
|
|
29
29
|
* Executes a persisted mutation, keeping track of mutations in-flight to ensure
|
|
30
30
|
* we don't execute the same mutation multiple times with the same values
|
|
31
31
|
* in the same component
|
|
32
32
|
*/
|
|
33
|
-
export declare
|
|
33
|
+
export declare function usePersistedMutation<MutationName extends keyof GraphQLQuery.MutationRegistry>(mutationName: MutationName, options?: ExecutionOptions): {
|
|
34
34
|
execute: (vars: GraphQLQuery.OperationVariables[MutationName], opts?: ExecuteMutationOptions) => Promise<GraphQLMutationResult<MutationName>>;
|
|
35
35
|
isExecuting: boolean;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* TODO: Subscription management
|
|
39
39
|
*/
|
|
40
|
-
export declare
|
|
40
|
+
export declare function usePersistedSubscription<SubscriptionName extends keyof GraphQLQuery.SubscriptionRegistry>(subscriptionName: SubscriptionName): void;
|
|
41
41
|
type UseOnMutationFn<M> = () => void;
|
|
42
42
|
/**
|
|
43
43
|
* Hook called when a mutation is issued, anywhere in the application.
|
|
44
44
|
* Useful for one-off situations where we want to subscribe and refetch something
|
|
45
45
|
* based on a mutation event
|
|
46
46
|
*/
|
|
47
|
-
export declare
|
|
47
|
+
export declare function useOnMutation<M extends keyof GraphQLQuery.MutationRegistry | '*'>(mutation: M | Array<M>, fn: UseOnMutationFn<M>): void;
|
|
48
48
|
export {};
|
package/cjs/graphqlHooks.js
CHANGED
|
@@ -12,8 +12,8 @@ const helpers_1 = require("./helpers");
|
|
|
12
12
|
* This hook keeps track of the value of the last render, so we're always guaranteed
|
|
13
13
|
* to have data here, even if it's potentially stale.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
const result =
|
|
15
|
+
function usePreloadedPersistedQuery(query, options) {
|
|
16
|
+
const result = usePersistedQuery(query, options);
|
|
17
17
|
const lastData = (0, react_1.useRef)(result.data);
|
|
18
18
|
const data = result.data ?? lastData.current;
|
|
19
19
|
if (!data) {
|
|
@@ -25,7 +25,7 @@ const usePreloadedPersistedQuery = (query, options) => {
|
|
|
25
25
|
}
|
|
26
26
|
}, [result.data]);
|
|
27
27
|
return { ...result, data };
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
exports.usePreloadedPersistedQuery = usePreloadedPersistedQuery;
|
|
30
30
|
/**
|
|
31
31
|
* Retrieves the persisted query from the cache,
|
|
@@ -38,7 +38,7 @@ exports.usePreloadedPersistedQuery = usePreloadedPersistedQuery;
|
|
|
38
38
|
* a) The TTL setting
|
|
39
39
|
* b) A mutation which invalidates the query
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
function usePersistedQuery(queryName, options) {
|
|
42
42
|
const cache = (0, context_1.useGraphQLQueryCache)();
|
|
43
43
|
const optionsRef = (0, react_1.useRef)(options);
|
|
44
44
|
// Ensure we always have the latest options in the optionsRef
|
|
@@ -76,14 +76,14 @@ const usePersistedQuery = (queryName, options) => {
|
|
|
76
76
|
...queryResult,
|
|
77
77
|
fetched: Boolean(queryResult),
|
|
78
78
|
}; // GraphQLQuery.QueryRegistry[QueryName];
|
|
79
|
-
}
|
|
79
|
+
}
|
|
80
80
|
exports.usePersistedQuery = usePersistedQuery;
|
|
81
81
|
/**
|
|
82
82
|
* TODO: Not working yet
|
|
83
83
|
* Creates a container for a query that isn't fetched immediately,
|
|
84
84
|
* but provides a loadQuery function to call
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
function useLazyPersistedQuery(query) {
|
|
87
87
|
const data = (0, react_1.useRef)(undefined);
|
|
88
88
|
const cache = (0, context_1.useGraphQLQueryCache)();
|
|
89
89
|
// const state = useState<'pending' | 'fetched' | 'loading' | 'stale'>('pending')
|
|
@@ -104,14 +104,14 @@ const useLazyPersistedQuery = (query) => {
|
|
|
104
104
|
stale,
|
|
105
105
|
fetched,
|
|
106
106
|
};
|
|
107
|
-
}
|
|
107
|
+
}
|
|
108
108
|
exports.useLazyPersistedQuery = useLazyPersistedQuery;
|
|
109
109
|
/**
|
|
110
110
|
* Executes a persisted mutation, keeping track of mutations in-flight to ensure
|
|
111
111
|
* we don't execute the same mutation multiple times with the same values
|
|
112
112
|
* in the same component
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
function usePersistedMutation(mutationName, options) {
|
|
115
115
|
const cache = (0, context_1.useGraphQLQueryCache)();
|
|
116
116
|
// Keeps track of whether we're executing the mutation or not, useful
|
|
117
117
|
// for showing loading states when we know the mutation is in-flight
|
|
@@ -144,21 +144,21 @@ const usePersistedMutation = (mutationName, options) => {
|
|
|
144
144
|
execute,
|
|
145
145
|
isExecuting: Boolean(isExecuting > 0),
|
|
146
146
|
};
|
|
147
|
-
}
|
|
147
|
+
}
|
|
148
148
|
exports.usePersistedMutation = usePersistedMutation;
|
|
149
149
|
/**
|
|
150
150
|
* TODO: Subscription management
|
|
151
151
|
*/
|
|
152
|
-
|
|
152
|
+
function usePersistedSubscription(subscriptionName) {
|
|
153
153
|
throw new Error(`usePersistedSubscription(${subscriptionName}) not yet supported`);
|
|
154
|
-
}
|
|
154
|
+
}
|
|
155
155
|
exports.usePersistedSubscription = usePersistedSubscription;
|
|
156
156
|
/**
|
|
157
157
|
* Hook called when a mutation is issued, anywhere in the application.
|
|
158
158
|
* Useful for one-off situations where we want to subscribe and refetch something
|
|
159
159
|
* based on a mutation event
|
|
160
160
|
*/
|
|
161
|
-
|
|
161
|
+
function useOnMutation(mutation, fn) {
|
|
162
162
|
const fnRef = (0, react_1.useRef)(fn);
|
|
163
163
|
const cache = (0, context_1.useGraphQLQueryCache)();
|
|
164
164
|
(0, react_1.useEffect)(() => {
|
|
@@ -171,5 +171,5 @@ const useOnMutation = (mutation, fn) => {
|
|
|
171
171
|
};
|
|
172
172
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
173
173
|
}, [cache, ...mutationDeps]);
|
|
174
|
-
}
|
|
174
|
+
}
|
|
175
175
|
exports.useOnMutation = useOnMutation;
|
package/mjs/GraphQLQueryCache.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
1
|
var _GraphQLQueryCache_instances, _GraphQLQueryCache_fetcher, _GraphQLQueryCache_endpoint, _GraphQLQueryCache_persistedOperations, _GraphQLQueryCache_persistedDocuments, _GraphQLQueryCache_configMeta, _GraphQLQueryCache_subscribedQueries, _GraphQLQueryCache_inFlight, _GraphQLQueryCache_cacheStore, _GraphQLQueryCache_runtimeCache, _GraphQLQueryCache_queryInvalidation, _GraphQLQueryCache_mutationInvalidation, _GraphQLQueryCache_effectsIssued, _GraphQLQueryCache_getKey, _GraphQLQueryCache_executeOperation, _GraphQLQueryCache_getMeta, _GraphQLQueryCache_fetch, _GraphQLQueryCache_shouldRefetchQuery, _GraphQLQueryCache_gcOperations;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
13
3
|
import isEqual from 'lodash.isequal';
|
|
14
4
|
import { graphqlNormalize } from 'graphql-normalize';
|
|
15
5
|
import { produce } from 'immer';
|
package/mjs/fragmentData.d.ts
CHANGED
package/mjs/fragmentData.js
CHANGED
package/mjs/graphqlHooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { GraphQLPreloadedQueryResult, GraphQLQueryLazyResult, GraphQLQueryR
|
|
|
6
6
|
* This hook keeps track of the value of the last render, so we're always guaranteed
|
|
7
7
|
* to have data here, even if it's potentially stale.
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare function usePreloadedPersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(query: QueryName, options: PersistedQueryOptions & QueryVariables<QueryName>): GraphQLPreloadedQueryResult<QueryName>;
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the persisted query from the cache,
|
|
12
12
|
* creating it from the cache if we don't have a mounted version
|
|
@@ -18,31 +18,31 @@ export declare const usePreloadedPersistedQuery: <QueryName extends never>(query
|
|
|
18
18
|
* a) The TTL setting
|
|
19
19
|
* b) A mutation which invalidates the query
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare function usePersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(queryName: QueryName, options: PersistedQueryOptions & QueryVariables<QueryName>): GraphQLQueryResult<QueryName>;
|
|
22
22
|
/**
|
|
23
23
|
* TODO: Not working yet
|
|
24
24
|
* Creates a container for a query that isn't fetched immediately,
|
|
25
25
|
* but provides a loadQuery function to call
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare function useLazyPersistedQuery<QueryName extends keyof GraphQLQuery.QueryRegistry>(query: QueryName): GraphQLQueryLazyResult<QueryName>;
|
|
28
28
|
/**
|
|
29
29
|
* Executes a persisted mutation, keeping track of mutations in-flight to ensure
|
|
30
30
|
* we don't execute the same mutation multiple times with the same values
|
|
31
31
|
* in the same component
|
|
32
32
|
*/
|
|
33
|
-
export declare
|
|
33
|
+
export declare function usePersistedMutation<MutationName extends keyof GraphQLQuery.MutationRegistry>(mutationName: MutationName, options?: ExecutionOptions): {
|
|
34
34
|
execute: (vars: GraphQLQuery.OperationVariables[MutationName], opts?: ExecuteMutationOptions) => Promise<GraphQLMutationResult<MutationName>>;
|
|
35
35
|
isExecuting: boolean;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* TODO: Subscription management
|
|
39
39
|
*/
|
|
40
|
-
export declare
|
|
40
|
+
export declare function usePersistedSubscription<SubscriptionName extends keyof GraphQLQuery.SubscriptionRegistry>(subscriptionName: SubscriptionName): void;
|
|
41
41
|
type UseOnMutationFn<M> = () => void;
|
|
42
42
|
/**
|
|
43
43
|
* Hook called when a mutation is issued, anywhere in the application.
|
|
44
44
|
* Useful for one-off situations where we want to subscribe and refetch something
|
|
45
45
|
* based on a mutation event
|
|
46
46
|
*/
|
|
47
|
-
export declare
|
|
47
|
+
export declare function useOnMutation<M extends keyof GraphQLQuery.MutationRegistry | '*'>(mutation: M | Array<M>, fn: UseOnMutationFn<M>): void;
|
|
48
48
|
export {};
|
package/mjs/graphqlHooks.js
CHANGED
|
@@ -9,7 +9,7 @@ import { serializeVariables } from './helpers';
|
|
|
9
9
|
* This hook keeps track of the value of the last render, so we're always guaranteed
|
|
10
10
|
* to have data here, even if it's potentially stale.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export function usePreloadedPersistedQuery(query, options) {
|
|
13
13
|
const result = usePersistedQuery(query, options);
|
|
14
14
|
const lastData = useRef(result.data);
|
|
15
15
|
const data = result.data ?? lastData.current;
|
|
@@ -22,7 +22,7 @@ export const usePreloadedPersistedQuery = (query, options) => {
|
|
|
22
22
|
}
|
|
23
23
|
}, [result.data]);
|
|
24
24
|
return { ...result, data };
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
/**
|
|
27
27
|
* Retrieves the persisted query from the cache,
|
|
28
28
|
* creating it from the cache if we don't have a mounted version
|
|
@@ -34,7 +34,7 @@ export const usePreloadedPersistedQuery = (query, options) => {
|
|
|
34
34
|
* a) The TTL setting
|
|
35
35
|
* b) A mutation which invalidates the query
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export function usePersistedQuery(queryName, options) {
|
|
38
38
|
const cache = useGraphQLQueryCache();
|
|
39
39
|
const optionsRef = useRef(options);
|
|
40
40
|
// Ensure we always have the latest options in the optionsRef
|
|
@@ -72,13 +72,13 @@ export const usePersistedQuery = (queryName, options) => {
|
|
|
72
72
|
...queryResult,
|
|
73
73
|
fetched: Boolean(queryResult),
|
|
74
74
|
}; // GraphQLQuery.QueryRegistry[QueryName];
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
76
|
/**
|
|
77
77
|
* TODO: Not working yet
|
|
78
78
|
* Creates a container for a query that isn't fetched immediately,
|
|
79
79
|
* but provides a loadQuery function to call
|
|
80
80
|
*/
|
|
81
|
-
export
|
|
81
|
+
export function useLazyPersistedQuery(query) {
|
|
82
82
|
const data = useRef(undefined);
|
|
83
83
|
const cache = useGraphQLQueryCache();
|
|
84
84
|
// const state = useState<'pending' | 'fetched' | 'loading' | 'stale'>('pending')
|
|
@@ -99,13 +99,13 @@ export const useLazyPersistedQuery = (query) => {
|
|
|
99
99
|
stale,
|
|
100
100
|
fetched,
|
|
101
101
|
};
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
/**
|
|
104
104
|
* Executes a persisted mutation, keeping track of mutations in-flight to ensure
|
|
105
105
|
* we don't execute the same mutation multiple times with the same values
|
|
106
106
|
* in the same component
|
|
107
107
|
*/
|
|
108
|
-
export
|
|
108
|
+
export function usePersistedMutation(mutationName, options) {
|
|
109
109
|
const cache = useGraphQLQueryCache();
|
|
110
110
|
// Keeps track of whether we're executing the mutation or not, useful
|
|
111
111
|
// for showing loading states when we know the mutation is in-flight
|
|
@@ -138,19 +138,19 @@ export const usePersistedMutation = (mutationName, options) => {
|
|
|
138
138
|
execute,
|
|
139
139
|
isExecuting: Boolean(isExecuting > 0),
|
|
140
140
|
};
|
|
141
|
-
}
|
|
141
|
+
}
|
|
142
142
|
/**
|
|
143
143
|
* TODO: Subscription management
|
|
144
144
|
*/
|
|
145
|
-
export
|
|
145
|
+
export function usePersistedSubscription(subscriptionName) {
|
|
146
146
|
throw new Error(`usePersistedSubscription(${subscriptionName}) not yet supported`);
|
|
147
|
-
}
|
|
147
|
+
}
|
|
148
148
|
/**
|
|
149
149
|
* Hook called when a mutation is issued, anywhere in the application.
|
|
150
150
|
* Useful for one-off situations where we want to subscribe and refetch something
|
|
151
151
|
* based on a mutation event
|
|
152
152
|
*/
|
|
153
|
-
export
|
|
153
|
+
export function useOnMutation(mutation, fn) {
|
|
154
154
|
const fnRef = useRef(fn);
|
|
155
155
|
const cache = useGraphQLQueryCache();
|
|
156
156
|
useEffect(() => {
|
|
@@ -163,4 +163,4 @@ export const useOnMutation = (mutation, fn) => {
|
|
|
163
163
|
};
|
|
164
164
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
165
|
}, [cache, ...mutationDeps]);
|
|
166
|
-
}
|
|
166
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-persisted",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "WIP: An Opinionated GraphQL Query Library, with a focus on fully persisted queries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"cjs/*"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"tslib": "^2.5.0",
|
|
31
32
|
"graphql-normalize": "^0.2.1",
|
|
32
33
|
"lodash.isequal": "^4.5.0"
|
|
33
34
|
},
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"clean": "rm -rf cjs && rm -rf mjs",
|
|
62
|
+
"predev": "pnpm install:example & pnpm install:example-server & pnpm install:example-codegen",
|
|
61
63
|
"dev": "concurrently 'pnpm dev:example' 'pnpm dev:codegen' 'pnpm dev:example-server'",
|
|
62
64
|
"dev:example": "cd example && pnpm dev",
|
|
63
65
|
"dev:codegen": "cd example/codegen && pnpm dev",
|
|
@@ -66,7 +68,6 @@
|
|
|
66
68
|
"build": "pnpm build:cjs && pnpm build:mjs",
|
|
67
69
|
"build:cjs": "tsc -p tsconfig.build.json --noEmit false --outDir cjs",
|
|
68
70
|
"build:mjs": "tsc -p tsconfig.build.json --noEmit false --outDir mjs --module ESNext --moduleResolution NodeNext",
|
|
69
|
-
"postinstall": "pnpm install:example & pnpm install:example-server & pnpm install:example-codegen",
|
|
70
71
|
"install:example": "cd example && pnpm i",
|
|
71
72
|
"install:example-server": "cd example/server && pnpm i",
|
|
72
73
|
"install:example-codegen": "cd example/codegen && pnpm i",
|