@orion-js/graphql 4.2.4 → 4.3.1
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/index.cjs +120 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +119 -83
- package/dist/index.js.map +1 -1
- package/package.json +22 -23
- package/LICENSE +0 -21
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ __export(index_exports, {
|
|
|
54
54
|
getTargetMetadata: () => getTargetMetadata,
|
|
55
55
|
getWebsockerViewer: () => getWebsockerViewer,
|
|
56
56
|
internalResolversMetadata: () => internalResolversMetadata,
|
|
57
|
+
registerPendingResolver: () => registerPendingResolver,
|
|
57
58
|
resolversSchemas: () => resolversSchemas_default,
|
|
58
59
|
serializeSchema: () => serializeSchema,
|
|
59
60
|
setGetWebsockerViewer: () => setGetWebsockerViewer,
|
|
@@ -493,7 +494,7 @@ function getScalar_default(fieldType) {
|
|
|
493
494
|
throw new Error(`Field type "${fieldType.name}" has no convertion to GraphQLType`);
|
|
494
495
|
}
|
|
495
496
|
|
|
496
|
-
// ../../node_modules/.
|
|
497
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/type.js
|
|
497
498
|
function type(input) {
|
|
498
499
|
if (input === null) {
|
|
499
500
|
return "Null";
|
|
@@ -506,21 +507,21 @@ function type(input) {
|
|
|
506
507
|
return typeResult === "AsyncFunction" ? "Promise" : typeResult;
|
|
507
508
|
}
|
|
508
509
|
|
|
509
|
-
// ../../node_modules/.
|
|
510
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/isArray.js
|
|
510
511
|
var { isArray } = Array;
|
|
511
512
|
|
|
512
|
-
// ../../node_modules/.
|
|
513
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/isInteger.js
|
|
513
514
|
function _isInteger(n) {
|
|
514
515
|
return n << 0 === n;
|
|
515
516
|
}
|
|
516
517
|
var isInteger = Number.isInteger || _isInteger;
|
|
517
518
|
|
|
518
|
-
// ../../node_modules/.
|
|
519
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/createPath.js
|
|
519
520
|
function createPath(path, delimiter = ".") {
|
|
520
521
|
return typeof path === "string" ? path.split(delimiter).map((x) => isInteger(x) ? Number(x) : x) : path;
|
|
521
522
|
}
|
|
522
523
|
|
|
523
|
-
// ../../node_modules/.
|
|
524
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/equals.js
|
|
524
525
|
function _indexOf(valueToFind, list) {
|
|
525
526
|
if (!isArray(list))
|
|
526
527
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
@@ -625,7 +626,7 @@ function equals(a, b) {
|
|
|
625
626
|
return false;
|
|
626
627
|
}
|
|
627
628
|
|
|
628
|
-
// ../../node_modules/.
|
|
629
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/isType.js
|
|
629
630
|
function isType(xType, x) {
|
|
630
631
|
if (arguments.length === 1) {
|
|
631
632
|
return (xHolder) => isType(xType, xHolder);
|
|
@@ -633,12 +634,12 @@ function isType(xType, x) {
|
|
|
633
634
|
return type(x) === xType;
|
|
634
635
|
}
|
|
635
636
|
|
|
636
|
-
// ../../node_modules/.
|
|
637
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/compare.js
|
|
637
638
|
function compare(a, b) {
|
|
638
639
|
return String(a) === String(b);
|
|
639
640
|
}
|
|
640
641
|
|
|
641
|
-
// ../../node_modules/.
|
|
642
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/_internals/includes.js
|
|
642
643
|
function includes(a, list) {
|
|
643
644
|
let index = -1;
|
|
644
645
|
const { length } = list;
|
|
@@ -648,7 +649,7 @@ function includes(a, list) {
|
|
|
648
649
|
return false;
|
|
649
650
|
}
|
|
650
651
|
|
|
651
|
-
// ../../node_modules/.
|
|
652
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/omit.js
|
|
652
653
|
function omit(propsToOmit, obj) {
|
|
653
654
|
if (arguments.length === 1) return (_obj) => omit(propsToOmit, _obj);
|
|
654
655
|
if (obj === null || obj === void 0)
|
|
@@ -661,7 +662,7 @@ function omit(propsToOmit, obj) {
|
|
|
661
662
|
return willReturn;
|
|
662
663
|
}
|
|
663
664
|
|
|
664
|
-
// ../../node_modules/.
|
|
665
|
+
// ../../node_modules/.bun/rambdax@11.3.1/node_modules/rambdax/src/isEmpty.js
|
|
665
666
|
function isEmpty(input) {
|
|
666
667
|
const inputType = type(input);
|
|
667
668
|
if (["Undefined", "NaN", "Number", "Null"].includes(inputType))
|
|
@@ -1375,60 +1376,78 @@ var createMutation = (options) => {
|
|
|
1375
1376
|
};
|
|
1376
1377
|
var serviceMetadata = /* @__PURE__ */ new WeakMap();
|
|
1377
1378
|
var internalResolversMetadata = /* @__PURE__ */ new WeakMap();
|
|
1379
|
+
var resolverEntriesByClass = /* @__PURE__ */ new Map();
|
|
1380
|
+
var pendingResolverEntries = {};
|
|
1378
1381
|
function Resolvers() {
|
|
1379
1382
|
return (target, context) => {
|
|
1380
1383
|
(0, import_services.Service)()(target, context);
|
|
1381
1384
|
serviceMetadata.set(target, { _serviceType: "resolvers" });
|
|
1385
|
+
if (Object.keys(pendingResolverEntries).length > 0) {
|
|
1386
|
+
resolverEntriesByClass.set(target, pendingResolverEntries);
|
|
1387
|
+
pendingResolverEntries = {};
|
|
1388
|
+
}
|
|
1382
1389
|
};
|
|
1383
1390
|
}
|
|
1384
1391
|
function Query(options = {}) {
|
|
1385
1392
|
return (method, context) => {
|
|
1386
1393
|
const propertyKey = String(context.name);
|
|
1387
|
-
context.
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
});
|
|
1394
|
+
if (context.kind === "method") {
|
|
1395
|
+
const params = getTargetMetadata(method, propertyKey, "params") || {};
|
|
1396
|
+
const returns = getTargetMetadata(method, propertyKey, "returns") || "string";
|
|
1397
|
+
const middlewares = getTargetMetadata(method, propertyKey, "middlewares") || [];
|
|
1398
|
+
pendingResolverEntries[propertyKey] = (instance) => (0, import_resolvers2.createResolver)({
|
|
1399
|
+
resolverId: propertyKey,
|
|
1400
|
+
params,
|
|
1401
|
+
returns,
|
|
1402
|
+
middlewares,
|
|
1403
|
+
...options,
|
|
1404
|
+
resolve: instance[propertyKey].bind(instance)
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
if (context.kind === "field") {
|
|
1408
|
+
pendingResolverEntries[propertyKey] = (instance) => instance[propertyKey];
|
|
1409
|
+
}
|
|
1404
1410
|
return method;
|
|
1405
1411
|
};
|
|
1406
1412
|
}
|
|
1407
1413
|
function Mutation(options = {}) {
|
|
1408
1414
|
return (method, context) => {
|
|
1409
1415
|
const propertyKey = String(context.name);
|
|
1410
|
-
context.
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1416
|
+
if (context.kind === "method") {
|
|
1417
|
+
const params = getTargetMetadata(method, propertyKey, "params") || {};
|
|
1418
|
+
const returns = getTargetMetadata(method, propertyKey, "returns") || "string";
|
|
1419
|
+
const middlewares = getTargetMetadata(method, propertyKey, "middlewares") || [];
|
|
1420
|
+
pendingResolverEntries[propertyKey] = (instance) => (0, import_resolvers2.createResolver)({
|
|
1421
|
+
resolverId: propertyKey,
|
|
1422
|
+
params,
|
|
1423
|
+
returns,
|
|
1424
|
+
middlewares,
|
|
1425
|
+
...options,
|
|
1426
|
+
mutation: true,
|
|
1427
|
+
resolve: instance[propertyKey].bind(instance)
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
if (context.kind === "field") {
|
|
1431
|
+
pendingResolverEntries[propertyKey] = (instance) => {
|
|
1432
|
+
instance[propertyKey].mutation = true;
|
|
1433
|
+
return instance[propertyKey];
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1429
1436
|
return method;
|
|
1430
1437
|
};
|
|
1431
1438
|
}
|
|
1439
|
+
function registerPendingResolver(propertyKey, setup) {
|
|
1440
|
+
pendingResolverEntries[propertyKey] = setup;
|
|
1441
|
+
}
|
|
1442
|
+
function initializeResolversIfNeeded(instance) {
|
|
1443
|
+
if (internalResolversMetadata.has(instance)) return;
|
|
1444
|
+
const entries = resolverEntriesByClass.get(instance.constructor) || {};
|
|
1445
|
+
const resolvers = {};
|
|
1446
|
+
for (const [key, setup] of Object.entries(entries)) {
|
|
1447
|
+
resolvers[key] = setup(instance);
|
|
1448
|
+
}
|
|
1449
|
+
internalResolversMetadata.set(instance, resolvers);
|
|
1450
|
+
}
|
|
1432
1451
|
function getServiceResolvers(target) {
|
|
1433
1452
|
const instance = (0, import_services.getInstance)(target);
|
|
1434
1453
|
const className = instance.constructor.name;
|
|
@@ -1440,6 +1459,7 @@ function getServiceResolvers(target) {
|
|
|
1440
1459
|
if (instanceMetadata._serviceType !== "resolvers") {
|
|
1441
1460
|
throw new Error(`${errorMessage}. Got class type ${instanceMetadata._serviceType}`);
|
|
1442
1461
|
}
|
|
1462
|
+
initializeResolversIfNeeded(instance);
|
|
1443
1463
|
const resolversMap = internalResolversMetadata.get(instance) || {};
|
|
1444
1464
|
return resolversMap;
|
|
1445
1465
|
}
|
|
@@ -1450,6 +1470,8 @@ var import_resolvers3 = require("@orion-js/resolvers");
|
|
|
1450
1470
|
var createModelResolver = import_resolvers3.createModelResolver;
|
|
1451
1471
|
var serviceMetadata2 = /* @__PURE__ */ new WeakMap();
|
|
1452
1472
|
var modelResolversMetadata = /* @__PURE__ */ new WeakMap();
|
|
1473
|
+
var modelResolverEntriesByClass = /* @__PURE__ */ new Map();
|
|
1474
|
+
var pendingModelResolverEntries = {};
|
|
1453
1475
|
function ModelResolvers(typedSchema, options = {}) {
|
|
1454
1476
|
return (target, context) => {
|
|
1455
1477
|
(0, import_services2.Service)()(target, context);
|
|
@@ -1466,37 +1488,47 @@ function ModelResolvers(typedSchema, options = {}) {
|
|
|
1466
1488
|
}
|
|
1467
1489
|
throw new Error(`You must specify a model name for the model resolvers (at: ${className})`);
|
|
1468
1490
|
})();
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
_modelName: modelName
|
|
1474
|
-
});
|
|
1491
|
+
serviceMetadata2.set(target, {
|
|
1492
|
+
_serviceType: "modelResolvers",
|
|
1493
|
+
options,
|
|
1494
|
+
_modelName: modelName
|
|
1475
1495
|
});
|
|
1496
|
+
if (Object.keys(pendingModelResolverEntries).length > 0) {
|
|
1497
|
+
modelResolverEntriesByClass.set(target, pendingModelResolverEntries);
|
|
1498
|
+
pendingModelResolverEntries = {};
|
|
1499
|
+
}
|
|
1476
1500
|
};
|
|
1477
1501
|
}
|
|
1478
1502
|
function ModelResolver(options = {}) {
|
|
1479
1503
|
return (method, context) => {
|
|
1480
1504
|
const propertyKey = String(context.name);
|
|
1481
|
-
context.
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
});
|
|
1505
|
+
if (context.kind === "method") {
|
|
1506
|
+
const params = getTargetMetadata(method, propertyKey, "params") || {};
|
|
1507
|
+
const returns = getTargetMetadata(method, propertyKey, "returns") || "string";
|
|
1508
|
+
const middlewares = getTargetMetadata(method, propertyKey, "middlewares") || [];
|
|
1509
|
+
pendingModelResolverEntries[propertyKey] = (instance) => createModelResolver({
|
|
1510
|
+
params,
|
|
1511
|
+
returns,
|
|
1512
|
+
middlewares,
|
|
1513
|
+
...options,
|
|
1514
|
+
resolve: instance[propertyKey].bind(instance)
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
if (context.kind === "field") {
|
|
1518
|
+
pendingModelResolverEntries[propertyKey] = (instance) => instance[propertyKey];
|
|
1519
|
+
}
|
|
1497
1520
|
return method;
|
|
1498
1521
|
};
|
|
1499
1522
|
}
|
|
1523
|
+
function initializeModelResolversIfNeeded(instance) {
|
|
1524
|
+
if (modelResolversMetadata.has(instance)) return;
|
|
1525
|
+
const entries = modelResolverEntriesByClass.get(instance.constructor) || {};
|
|
1526
|
+
const resolvers = {};
|
|
1527
|
+
for (const [key, setup] of Object.entries(entries)) {
|
|
1528
|
+
resolvers[key] = setup(instance);
|
|
1529
|
+
}
|
|
1530
|
+
modelResolversMetadata.set(instance, resolvers);
|
|
1531
|
+
}
|
|
1500
1532
|
function getServiceModelResolvers(target) {
|
|
1501
1533
|
const instance = (0, import_services2.getInstance)(target);
|
|
1502
1534
|
if (!serviceMetadata2.has(instance.constructor)) {
|
|
@@ -1510,6 +1542,7 @@ function getServiceModelResolvers(target) {
|
|
|
1510
1542
|
"You must pass a class decorated with @ModelResolvers to getServiceModelResolvers"
|
|
1511
1543
|
);
|
|
1512
1544
|
}
|
|
1545
|
+
initializeModelResolversIfNeeded(instance);
|
|
1513
1546
|
const modelResolversMap = modelResolversMetadata.get(instance) || {};
|
|
1514
1547
|
return {
|
|
1515
1548
|
[instanceMetadata._modelName]: modelResolversMap
|
|
@@ -1520,31 +1553,33 @@ function getServiceModelResolvers(target) {
|
|
|
1520
1553
|
var import_services3 = require("@orion-js/services");
|
|
1521
1554
|
var serviceMetadata3 = /* @__PURE__ */ new WeakMap();
|
|
1522
1555
|
var subscriptionsMetadata = /* @__PURE__ */ new WeakMap();
|
|
1556
|
+
var subscriptionEntriesByClass = /* @__PURE__ */ new Map();
|
|
1557
|
+
var pendingSubscriptionEntries = {};
|
|
1523
1558
|
function Subscriptions() {
|
|
1524
1559
|
return (target, context) => {
|
|
1525
1560
|
(0, import_services3.Service)()(target, context);
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1561
|
+
serviceMetadata3.set(target, { _serviceType: "subscriptions" });
|
|
1562
|
+
if (Object.keys(pendingSubscriptionEntries).length > 0) {
|
|
1563
|
+
subscriptionEntriesByClass.set(target, pendingSubscriptionEntries);
|
|
1564
|
+
pendingSubscriptionEntries = {};
|
|
1565
|
+
}
|
|
1529
1566
|
};
|
|
1530
1567
|
}
|
|
1531
1568
|
function Subscription() {
|
|
1532
1569
|
return (_method, context) => {
|
|
1533
1570
|
const propertyKey = String(context.name);
|
|
1534
|
-
|
|
1535
|
-
const repo = serviceMetadata3.get(this.constructor);
|
|
1536
|
-
if (!repo || repo._serviceType !== "subscriptions") {
|
|
1537
|
-
throw new Error(
|
|
1538
|
-
"You must pass a class decorated with @Subscriptions if you want to use @Subscription"
|
|
1539
|
-
);
|
|
1540
|
-
}
|
|
1541
|
-
const subscriptions = subscriptionsMetadata.get(this) || {};
|
|
1542
|
-
subscriptions[propertyKey] = this[propertyKey];
|
|
1543
|
-
subscriptionsMetadata.set(this, subscriptions);
|
|
1544
|
-
this[propertyKey] = subscriptions[propertyKey];
|
|
1545
|
-
});
|
|
1571
|
+
pendingSubscriptionEntries[propertyKey] = (instance) => instance[propertyKey];
|
|
1546
1572
|
};
|
|
1547
1573
|
}
|
|
1574
|
+
function initializeSubscriptionsIfNeeded(instance) {
|
|
1575
|
+
if (subscriptionsMetadata.has(instance)) return;
|
|
1576
|
+
const entries = subscriptionEntriesByClass.get(instance.constructor) || {};
|
|
1577
|
+
const subscriptions = {};
|
|
1578
|
+
for (const [key, setup] of Object.entries(entries)) {
|
|
1579
|
+
subscriptions[key] = setup(instance);
|
|
1580
|
+
}
|
|
1581
|
+
subscriptionsMetadata.set(instance, subscriptions);
|
|
1582
|
+
}
|
|
1548
1583
|
function getServiceSubscriptions(target) {
|
|
1549
1584
|
const instance = (0, import_services3.getInstance)(target);
|
|
1550
1585
|
if (!serviceMetadata3.has(instance.constructor)) {
|
|
@@ -1558,6 +1593,7 @@ function getServiceSubscriptions(target) {
|
|
|
1558
1593
|
"You must pass a class decorated with @Subscriptions to getServiceSubscriptions"
|
|
1559
1594
|
);
|
|
1560
1595
|
}
|
|
1596
|
+
initializeSubscriptionsIfNeeded(instance);
|
|
1561
1597
|
const subscriptionsMap = subscriptionsMetadata.get(instance) || {};
|
|
1562
1598
|
return subscriptionsMap;
|
|
1563
1599
|
}
|
|
@@ -1591,6 +1627,7 @@ var createSubscription2 = subscription_default;
|
|
|
1591
1627
|
getTargetMetadata,
|
|
1592
1628
|
getWebsockerViewer,
|
|
1593
1629
|
internalResolversMetadata,
|
|
1630
|
+
registerPendingResolver,
|
|
1594
1631
|
resolversSchemas,
|
|
1595
1632
|
serializeSchema,
|
|
1596
1633
|
setGetWebsockerViewer,
|