@orion-js/graphql 4.0.0-next.3 → 4.0.0-next.4
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 +415 -328
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -27
- package/dist/index.d.ts +58 -27
- package/dist/index.js +420 -325
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -254,10 +254,13 @@ import { GraphQLSchema } from "graphql";
|
|
|
254
254
|
import { GraphQLObjectType as GraphQLObjectType2 } from "graphql";
|
|
255
255
|
|
|
256
256
|
// src/buildSchema/getType/index.ts
|
|
257
|
-
import isPlainObject2 from "lodash/isPlainObject";
|
|
258
257
|
import isArray2 from "lodash/isArray";
|
|
259
258
|
import { GraphQLList as GraphQLList2, GraphQLObjectType } from "graphql";
|
|
260
|
-
import {
|
|
259
|
+
import {
|
|
260
|
+
getFieldType as getFieldType2,
|
|
261
|
+
getSchemaWithMetadataFromAnyOrionForm,
|
|
262
|
+
isSchemaLike
|
|
263
|
+
} from "@orion-js/schema";
|
|
261
264
|
|
|
262
265
|
// src/buildSchema/getType/BigIntScalar.ts
|
|
263
266
|
import { GraphQLScalarType } from "graphql";
|
|
@@ -378,9 +381,11 @@ import { GraphQLList, GraphQLInputObjectType } from "graphql";
|
|
|
378
381
|
import { getFieldType } from "@orion-js/schema";
|
|
379
382
|
|
|
380
383
|
// src/resolversSchemas/getStaticFields.ts
|
|
381
|
-
function getStaticFields(
|
|
382
|
-
const schema = model.getSchema();
|
|
384
|
+
function getStaticFields(schema) {
|
|
383
385
|
if (!schema) return [];
|
|
386
|
+
if (schema.getSchema) {
|
|
387
|
+
schema = schema.getSchema();
|
|
388
|
+
}
|
|
384
389
|
const keys = Object.keys(schema).filter((key) => !key.startsWith("__"));
|
|
385
390
|
return keys.map((key) => {
|
|
386
391
|
const field = schema[key];
|
|
@@ -392,49 +397,57 @@ function getStaticFields(model) {
|
|
|
392
397
|
}
|
|
393
398
|
|
|
394
399
|
// src/buildSchema/getArgs/getField.ts
|
|
400
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("Symbol.metadata"));
|
|
395
401
|
var storedModelInput = {};
|
|
396
|
-
var
|
|
397
|
-
if (storedModelInput[model.name]) {
|
|
398
|
-
|
|
402
|
+
var getCachedModelInput = (model, fields) => {
|
|
403
|
+
if (!storedModelInput[model.name]) {
|
|
404
|
+
storedModelInput[model.name] = new GraphQLInputObjectType({
|
|
405
|
+
name: `${model.name}Input`,
|
|
406
|
+
fields
|
|
407
|
+
});
|
|
399
408
|
}
|
|
400
|
-
storedModelInput[model.name] = new GraphQLInputObjectType({
|
|
401
|
-
name: model.name + "Input",
|
|
402
|
-
fields
|
|
403
|
-
});
|
|
404
409
|
return storedModelInput[model.name];
|
|
405
410
|
};
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
411
|
+
var resolveModelFields = (model) => {
|
|
412
|
+
const fields = {};
|
|
413
|
+
for (const field of getStaticFields(model)) {
|
|
414
|
+
fields[field.key] = { type: resolveType(field.type) };
|
|
409
415
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
for (const field of getStaticFields(model)) {
|
|
418
|
-
fields[field.key] = {
|
|
419
|
-
type: getParams(field.type)
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
return getModelInput(model, fields);
|
|
423
|
-
} else {
|
|
424
|
-
const schemaType = getFieldType(type);
|
|
425
|
-
const graphQLType = getScalar_default(schemaType);
|
|
426
|
-
return graphQLType;
|
|
416
|
+
return fields;
|
|
417
|
+
};
|
|
418
|
+
var resolveArrayType = (type) => new GraphQLList(resolveType(type[0]));
|
|
419
|
+
var resolvePlainObjectOrModelType = (type) => {
|
|
420
|
+
const model = type.__isModel ? type : type.__model;
|
|
421
|
+
if (!model || !model.__isModel) {
|
|
422
|
+
throw new Error("A type is not a Model");
|
|
427
423
|
}
|
|
428
|
-
|
|
424
|
+
const fields = resolveModelFields(model);
|
|
425
|
+
return getCachedModelInput(model, fields);
|
|
426
|
+
};
|
|
427
|
+
var resolveType = (type) => {
|
|
428
|
+
var _a;
|
|
429
|
+
if (!type) throw new Error("No type specified");
|
|
430
|
+
if ((_a = type == null ? void 0 : type[Symbol.metadata]) == null ? void 0 : _a._getModel) {
|
|
431
|
+
const model = type[Symbol.metadata]._getModel();
|
|
432
|
+
return resolveType(model);
|
|
433
|
+
}
|
|
434
|
+
if (isArray(type)) return resolveArrayType(type);
|
|
435
|
+
if (!type.__isFieldType && (isPlainObject(type) || type.__isModel)) {
|
|
436
|
+
return resolvePlainObjectOrModelType(type);
|
|
437
|
+
}
|
|
438
|
+
const schemaType = getFieldType(type);
|
|
439
|
+
return getScalar_default(schemaType);
|
|
440
|
+
};
|
|
441
|
+
var getField_default = resolveType;
|
|
429
442
|
|
|
430
443
|
// src/buildSchema/getArgs/index.ts
|
|
431
|
-
function getArgs_default(params) {
|
|
444
|
+
async function getArgs_default(params) {
|
|
432
445
|
if (!params) return;
|
|
433
446
|
if (Object.keys(params).length === 0) return;
|
|
434
447
|
const fields = {};
|
|
435
448
|
for (const key of Object.keys(params)) {
|
|
436
449
|
try {
|
|
437
|
-
const type =
|
|
450
|
+
const type = getField_default(params[key].type);
|
|
438
451
|
fields[key] = { type };
|
|
439
452
|
} catch (error) {
|
|
440
453
|
throw new Error(`Error creating GraphQL resolver params argument ${key}: ${error.message}`);
|
|
@@ -447,10 +460,10 @@ function getArgs_default(params) {
|
|
|
447
460
|
import crypto from "crypto";
|
|
448
461
|
import { GraphQLError } from "graphql";
|
|
449
462
|
function errorHandler(error, data) {
|
|
450
|
-
const message = `Error in resolver "${data.name}" ${data.
|
|
463
|
+
const message = `Error in resolver "${data.name}" ${data.schema ? `of model "${data.schema.__modelName}"` : ""}`;
|
|
451
464
|
const hash = crypto.createHash("sha1").update(error.message, "utf8").digest("hex").substring(0, 10);
|
|
452
465
|
error.hash = hash;
|
|
453
|
-
if (error
|
|
466
|
+
if (error == null ? void 0 : error.isOrionError) {
|
|
454
467
|
console.warn(message, error);
|
|
455
468
|
throw new GraphQLError(error.message, {
|
|
456
469
|
originalError: error,
|
|
@@ -462,33 +475,32 @@ function errorHandler(error, data) {
|
|
|
462
475
|
info: error.getInfo()
|
|
463
476
|
}
|
|
464
477
|
});
|
|
465
|
-
} else {
|
|
466
|
-
console.error(message, error);
|
|
467
|
-
throw new GraphQLError(`${error.message} [${hash}]`, {
|
|
468
|
-
// originalError: error,
|
|
469
|
-
extensions: {
|
|
470
|
-
isOrionError: false,
|
|
471
|
-
isValidationError: false,
|
|
472
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
473
|
-
hash
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
478
|
}
|
|
479
|
+
console.error(message, error);
|
|
480
|
+
throw new GraphQLError(`${error.message} [${hash}]`, {
|
|
481
|
+
// originalError: error,
|
|
482
|
+
extensions: {
|
|
483
|
+
isOrionError: false,
|
|
484
|
+
isValidationError: false,
|
|
485
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
486
|
+
hash
|
|
487
|
+
}
|
|
488
|
+
});
|
|
477
489
|
}
|
|
478
490
|
|
|
479
491
|
// src/buildSchema/getType/getTypeAsResolver.ts
|
|
480
|
-
function getTypeAsResolver_default({ resolver:
|
|
481
|
-
const type = getGraphQLType2(
|
|
482
|
-
const args = getArgs_default(
|
|
492
|
+
function getTypeAsResolver_default({ resolver: resolver2, getGraphQLType: getGraphQLType2, options, schema }) {
|
|
493
|
+
const type = getGraphQLType2(resolver2.returns, options);
|
|
494
|
+
const args = getArgs_default(resolver2.params);
|
|
483
495
|
return {
|
|
484
496
|
type,
|
|
485
497
|
args,
|
|
486
498
|
async resolve(item, params, context, info) {
|
|
487
499
|
try {
|
|
488
|
-
const result = await
|
|
500
|
+
const result = await resolver2.resolve(item, params, context, info);
|
|
489
501
|
return result;
|
|
490
502
|
} catch (error) {
|
|
491
|
-
errorHandler(error, { context, resolver:
|
|
503
|
+
errorHandler(error, { context, resolver: resolver2, options, schema });
|
|
492
504
|
throw error;
|
|
493
505
|
}
|
|
494
506
|
}
|
|
@@ -496,97 +508,117 @@ function getTypeAsResolver_default({ resolver: resolver4, getGraphQLType: getGra
|
|
|
496
508
|
}
|
|
497
509
|
|
|
498
510
|
// src/resolversSchemas/getDynamicFields.ts
|
|
499
|
-
function
|
|
500
|
-
|
|
511
|
+
function getResolvers(schema) {
|
|
512
|
+
if (typeof schema.getResolvers === "function") {
|
|
513
|
+
console.warn("Models are deprecated");
|
|
514
|
+
return schema.getResolvers();
|
|
515
|
+
}
|
|
516
|
+
if (schema.__resolvers) {
|
|
517
|
+
return schema.__resolvers;
|
|
518
|
+
}
|
|
519
|
+
return {};
|
|
520
|
+
}
|
|
521
|
+
function getDynamicFields(schema) {
|
|
522
|
+
const resolvers = getResolvers(schema);
|
|
501
523
|
if (!resolvers) return [];
|
|
502
524
|
const keys = Object.keys(resolvers);
|
|
503
525
|
return keys.map((key) => {
|
|
504
|
-
const
|
|
526
|
+
const resolver2 = resolvers[key];
|
|
505
527
|
return {
|
|
506
|
-
...
|
|
528
|
+
...resolver2,
|
|
507
529
|
key
|
|
508
530
|
};
|
|
509
|
-
}).filter((
|
|
531
|
+
}).filter((resolver2) => !resolver2.private);
|
|
510
532
|
}
|
|
511
533
|
|
|
512
534
|
// src/resolversSchemas/getModelLoadedResolvers.ts
|
|
513
|
-
function getModelLoadedResolvers(
|
|
535
|
+
function getModelLoadedResolvers(schema, options) {
|
|
514
536
|
if (!options.modelResolvers) return [];
|
|
515
|
-
const resolvers = options.modelResolvers[
|
|
537
|
+
const resolvers = options.modelResolvers[schema.__modelName];
|
|
516
538
|
if (!resolvers) return [];
|
|
517
539
|
const keys = Object.keys(resolvers);
|
|
518
540
|
return keys.map((key) => {
|
|
519
|
-
const
|
|
541
|
+
const resolver2 = resolvers[key];
|
|
520
542
|
return {
|
|
521
|
-
...
|
|
543
|
+
...resolver2,
|
|
522
544
|
key
|
|
523
545
|
};
|
|
524
|
-
}).filter((
|
|
546
|
+
}).filter((resolver2) => !resolver2.private);
|
|
525
547
|
}
|
|
526
548
|
|
|
527
549
|
// src/buildSchema/getType/index.ts
|
|
550
|
+
import { isEqual } from "lodash";
|
|
551
|
+
var createGraphQLObjectType = (modelName, schema, options) => new GraphQLObjectType({
|
|
552
|
+
name: modelName,
|
|
553
|
+
fields: () => buildFields(schema, options)
|
|
554
|
+
});
|
|
555
|
+
var buildFields = (schema, options) => {
|
|
556
|
+
const fields = {};
|
|
557
|
+
const addStaticFields = () => {
|
|
558
|
+
for (const field of getStaticFields(schema)) {
|
|
559
|
+
try {
|
|
560
|
+
fields[field.key] = field.graphQLResolver ? getTypeAsResolver_default({ resolver: field.graphQLResolver, getGraphQLType, options, schema }) : { type: getGraphQLType(field.type, options) };
|
|
561
|
+
} catch (error) {
|
|
562
|
+
throw new Error(`Error getting type for ${field.key}: ${error.message}`);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const addDynamicFields = () => {
|
|
567
|
+
for (const resolver2 of getDynamicFields(schema)) {
|
|
568
|
+
try {
|
|
569
|
+
fields[resolver2.key] = getTypeAsResolver_default({ resolver: resolver2, getGraphQLType, options, schema });
|
|
570
|
+
} catch (error) {
|
|
571
|
+
throw new Error(
|
|
572
|
+
`Error getting resolver type for resolver "${resolver2.key}": ${error.message}`
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
const addModelLoadedResolvers = () => {
|
|
578
|
+
for (const resolver2 of getModelLoadedResolvers(schema, options)) {
|
|
579
|
+
try {
|
|
580
|
+
fields[resolver2.key] = getTypeAsResolver_default({ resolver: resolver2, getGraphQLType, options, schema });
|
|
581
|
+
} catch (error) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
`Error getting resolver type for resolver "${resolver2.key}": ${error.message}`
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
addStaticFields();
|
|
589
|
+
addDynamicFields();
|
|
590
|
+
addModelLoadedResolvers();
|
|
591
|
+
return fields;
|
|
592
|
+
};
|
|
593
|
+
var registeredGraphQLTypes = /* @__PURE__ */ new Map();
|
|
528
594
|
function getGraphQLType(type, options) {
|
|
529
|
-
if (!type)
|
|
530
|
-
throw new Error("Type is undefined");
|
|
531
|
-
}
|
|
595
|
+
if (!type) throw new Error("Type is undefined");
|
|
532
596
|
if (isArray2(type)) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
getGraphQLType,
|
|
551
|
-
options,
|
|
552
|
-
model
|
|
553
|
-
});
|
|
554
|
-
} else {
|
|
555
|
-
fields[field.key] = {
|
|
556
|
-
type: getGraphQLType(field.type, options)
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
} catch (error) {
|
|
560
|
-
throw new Error(`Error getting type for ${field.key} ${error.message}`);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
for (const resolver4 of getDynamicFields(model)) {
|
|
564
|
-
try {
|
|
565
|
-
fields[resolver4.key] = getTypeAsResolver_default({ resolver: resolver4, getGraphQLType, options, model });
|
|
566
|
-
} catch (error) {
|
|
567
|
-
throw new Error(
|
|
568
|
-
`Error getting resolver type for resolver "${resolver4.key}": ${error.message}`
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
for (const resolver4 of getModelLoadedResolvers(model, options)) {
|
|
573
|
-
try {
|
|
574
|
-
fields[resolver4.key] = getTypeAsResolver_default({ resolver: resolver4, getGraphQLType, options, model });
|
|
575
|
-
} catch (error) {
|
|
576
|
-
throw new Error(
|
|
577
|
-
`Error getting resolver type for resolver "${resolver4.key}": ${error.message}`
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return fields;
|
|
597
|
+
return new GraphQLList2(getGraphQLType(type[0], options));
|
|
598
|
+
}
|
|
599
|
+
if (isSchemaLike(type)) {
|
|
600
|
+
const schema = getSchemaWithMetadataFromAnyOrionForm(type);
|
|
601
|
+
const modelName = schema.__modelName;
|
|
602
|
+
if (schema.__graphQLType) {
|
|
603
|
+
return schema.__graphQLType;
|
|
604
|
+
}
|
|
605
|
+
if (!modelName) {
|
|
606
|
+
throw new Error(
|
|
607
|
+
`Schema name is not defined. Register a name with schemaWithName. Schema: ${JSON.stringify(schema)}`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
if (registeredGraphQLTypes.has(modelName)) {
|
|
611
|
+
const { graphQLType: graphQLType2, schema: registeredSchema } = registeredGraphQLTypes.get(modelName);
|
|
612
|
+
if (isEqual(registeredSchema, schema)) {
|
|
613
|
+
return graphQLType2;
|
|
582
614
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const graphQLType = getScalar_default(schemaType);
|
|
615
|
+
throw new Error(`Schema named "${modelName}" already registered`);
|
|
616
|
+
}
|
|
617
|
+
const graphQLType = createGraphQLObjectType(modelName, schema, options);
|
|
618
|
+
registeredGraphQLTypes.set(modelName, { schema, graphQLType });
|
|
588
619
|
return graphQLType;
|
|
589
620
|
}
|
|
621
|
+
return getScalar_default(getFieldType2(type));
|
|
590
622
|
}
|
|
591
623
|
|
|
592
624
|
// src/buildSchema/getResolvers/resolversStore.ts
|
|
@@ -600,21 +632,21 @@ async function getResolvers_default(options, mutation) {
|
|
|
600
632
|
name: key,
|
|
601
633
|
resolver: resolvers[key]
|
|
602
634
|
};
|
|
603
|
-
}).filter(({ resolver:
|
|
635
|
+
}).filter(({ resolver: resolver2 }) => !!resolver2.mutation === !!mutation).filter(({ resolver: resolver2 }) => !resolver2.private);
|
|
604
636
|
const fields = {};
|
|
605
|
-
for (const { resolver:
|
|
606
|
-
resolversStore[name] =
|
|
607
|
-
const type = await getGraphQLType(
|
|
608
|
-
const args = await getArgs_default(
|
|
637
|
+
for (const { resolver: resolver2, name } of filteredResolvers) {
|
|
638
|
+
resolversStore[name] = resolver2;
|
|
639
|
+
const type = await getGraphQLType(resolver2.returns, options);
|
|
640
|
+
const args = await getArgs_default(resolver2.params);
|
|
609
641
|
fields[name] = {
|
|
610
642
|
type,
|
|
611
643
|
args,
|
|
612
|
-
async resolve(
|
|
644
|
+
async resolve(_root, params, context, info) {
|
|
613
645
|
try {
|
|
614
|
-
const result = await
|
|
646
|
+
const result = await resolver2.resolve(params, context, info);
|
|
615
647
|
return result;
|
|
616
648
|
} catch (error) {
|
|
617
|
-
errorHandler(error, { context, resolver:
|
|
649
|
+
errorHandler(error, { context, resolver: resolver2, options, name });
|
|
618
650
|
throw error;
|
|
619
651
|
}
|
|
620
652
|
}
|
|
@@ -808,6 +840,7 @@ async function startGraphQL_default(options) {
|
|
|
808
840
|
path: "/graphql",
|
|
809
841
|
bodyParser: "json",
|
|
810
842
|
async resolve(req, res, viewer) {
|
|
843
|
+
;
|
|
811
844
|
req._viewer = viewer;
|
|
812
845
|
return middleware(req, res, req.next);
|
|
813
846
|
}
|
|
@@ -816,124 +849,130 @@ async function startGraphQL_default(options) {
|
|
|
816
849
|
}
|
|
817
850
|
|
|
818
851
|
// src/resolversSchemas/params.ts
|
|
819
|
-
import {
|
|
852
|
+
import { createResolver } from "@orion-js/resolvers";
|
|
820
853
|
import { UserError } from "@orion-js/helpers";
|
|
821
854
|
|
|
855
|
+
// src/resolversSchemas/ResolverParamsInfo.ts
|
|
856
|
+
import { schemaWithName } from "@orion-js/schema";
|
|
857
|
+
var ResolverParamsInfo_default = schemaWithName("ResolverParams", {
|
|
858
|
+
name: {
|
|
859
|
+
type: "string"
|
|
860
|
+
},
|
|
861
|
+
params: {
|
|
862
|
+
type: "blackbox"
|
|
863
|
+
},
|
|
864
|
+
result: {
|
|
865
|
+
type: "string"
|
|
866
|
+
},
|
|
867
|
+
basicResultQuery: {
|
|
868
|
+
type: "string"
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// src/resolversSchemas/serializeSchema.ts
|
|
873
|
+
import { getSchemaFromAnyOrionForm } from "@orion-js/schema";
|
|
874
|
+
|
|
822
875
|
// src/resolversSchemas/getField.ts
|
|
823
|
-
import
|
|
824
|
-
|
|
825
|
-
|
|
876
|
+
import {
|
|
877
|
+
getFieldType as getFieldType3,
|
|
878
|
+
getSchemaWithMetadataFromAnyOrionForm as getSchemaWithMetadataFromAnyOrionForm2,
|
|
879
|
+
isSchemaLike as isSchemaLike2
|
|
880
|
+
} from "@orion-js/schema";
|
|
826
881
|
import omit2 from "lodash/omit";
|
|
827
|
-
async function
|
|
828
|
-
|
|
829
|
-
if (
|
|
830
|
-
const
|
|
831
|
-
return await getParams2({ ...field, type: model });
|
|
832
|
-
} else if (isArray3(type)) {
|
|
833
|
-
const serialized = await getParams2({ ...field, type: type[0] });
|
|
882
|
+
async function getParams(field) {
|
|
883
|
+
const { type } = field;
|
|
884
|
+
if (Array.isArray(type)) {
|
|
885
|
+
const serialized = await getParams({ ...field, type: type[0] });
|
|
834
886
|
return {
|
|
835
887
|
...serialized,
|
|
836
888
|
type: [serialized.type],
|
|
837
889
|
__graphQLType: `[${serialized.__graphQLType}]`
|
|
838
890
|
};
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
|
|
891
|
+
}
|
|
892
|
+
const isSchema = isSchemaLike2(type);
|
|
893
|
+
if (isSchema) {
|
|
894
|
+
const schemaOfType = getSchemaWithMetadataFromAnyOrionForm2(type);
|
|
895
|
+
const modelName = schemaOfType.__modelName;
|
|
896
|
+
if (!modelName) {
|
|
897
|
+
throw new Error("The schema needs a model name to be serialized for GraphQL");
|
|
898
|
+
}
|
|
842
899
|
const fields = {};
|
|
843
|
-
for (const field2 of getStaticFields(
|
|
844
|
-
fields[field2.key] = await
|
|
900
|
+
for (const field2 of getStaticFields(schemaOfType)) {
|
|
901
|
+
fields[field2.key] = await getParams(field2);
|
|
845
902
|
}
|
|
846
903
|
return {
|
|
847
904
|
...omit2(field, "key"),
|
|
848
905
|
type: fields,
|
|
849
|
-
__graphQLType:
|
|
850
|
-
};
|
|
851
|
-
} else {
|
|
852
|
-
const schemaType = await getFieldType3(type);
|
|
853
|
-
const graphQLType = await getScalar_default(schemaType);
|
|
854
|
-
return {
|
|
855
|
-
...omit2(field, "key"),
|
|
856
|
-
type: schemaType.name,
|
|
857
|
-
__graphQLType: graphQLType.name
|
|
906
|
+
__graphQLType: `${modelName}Input`
|
|
858
907
|
};
|
|
859
908
|
}
|
|
909
|
+
const schemaType = getFieldType3(type);
|
|
910
|
+
const graphQLType = await getScalar_default(schemaType);
|
|
911
|
+
return {
|
|
912
|
+
...omit2(field, "key"),
|
|
913
|
+
type: schemaType.name,
|
|
914
|
+
__graphQLType: graphQLType.name
|
|
915
|
+
};
|
|
860
916
|
}
|
|
861
917
|
|
|
862
918
|
// src/resolversSchemas/serializeSchema.ts
|
|
919
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("Symbol.metadata"));
|
|
863
920
|
async function serializeSchema(params) {
|
|
864
921
|
if (!params) return;
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
if (Object.keys(params).length === 0) return;
|
|
922
|
+
const schema = getSchemaFromAnyOrionForm(params);
|
|
923
|
+
if (Object.keys(schema).length === 0) return;
|
|
869
924
|
const fields = {};
|
|
870
|
-
for (const key of Object.keys(
|
|
871
|
-
const field =
|
|
872
|
-
fields[key] = await
|
|
925
|
+
for (const key of Object.keys(schema).filter((key2) => !key2.startsWith("__"))) {
|
|
926
|
+
const field = schema[key];
|
|
927
|
+
fields[key] = await getParams(field);
|
|
873
928
|
}
|
|
874
929
|
return fields;
|
|
875
930
|
}
|
|
876
931
|
|
|
932
|
+
// src/resolversSchemas/params.ts
|
|
933
|
+
import { getSchemaFromAnyOrionForm as getSchemaFromAnyOrionForm3, isSchemaLike as isSchemaLike4 } from "@orion-js/schema";
|
|
934
|
+
|
|
877
935
|
// src/resolversSchemas/getBasicResultQuery.ts
|
|
878
|
-
import
|
|
936
|
+
import isArray3 from "lodash/isArray";
|
|
937
|
+
import { getSchemaFromAnyOrionForm as getSchemaFromAnyOrionForm2, isSchemaLike as isSchemaLike3 } from "@orion-js/schema";
|
|
879
938
|
async function getBasicQuery(field) {
|
|
880
939
|
if (!field.type) return "";
|
|
881
|
-
if (
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
return `${key}{ ${fields.join(" ")} }`;
|
|
889
|
-
} else {
|
|
940
|
+
if (isArray3(field.type)) {
|
|
941
|
+
return getBasicQuery({
|
|
942
|
+
...field,
|
|
943
|
+
type: field.type[0]
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
if (!isSchemaLike3(field.type)) {
|
|
890
947
|
return field.key;
|
|
891
948
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
import { resolver } from "@orion-js/resolvers";
|
|
897
|
-
import { isArray as isArray5 } from "lodash";
|
|
898
|
-
var resolverReturnsIsModel = (returns) => {
|
|
899
|
-
return returns && returns.__isModel;
|
|
900
|
-
};
|
|
901
|
-
var ResolverParamsInfo_default = createModel({
|
|
902
|
-
name: "ResolverParams",
|
|
903
|
-
schema: {
|
|
904
|
-
name: {
|
|
905
|
-
type: String
|
|
906
|
-
}
|
|
907
|
-
},
|
|
908
|
-
resolvers: {
|
|
909
|
-
params: resolver({
|
|
910
|
-
returns: "blackbox",
|
|
911
|
-
resolve: async function({ resolver: resolver4 }) {
|
|
912
|
-
return await serializeSchema(resolver4.params);
|
|
913
|
-
}
|
|
914
|
-
}),
|
|
915
|
-
result: resolver({
|
|
916
|
-
returns: String,
|
|
917
|
-
resolve: async function({ resolver: resolver4 }) {
|
|
918
|
-
const returns = isArray5(resolver4.returns) ? resolver4.returns[0] : resolver4.returns;
|
|
919
|
-
if (resolverReturnsIsModel(returns)) return returns.name;
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
}),
|
|
923
|
-
basicResultQuery: resolver({
|
|
924
|
-
returns: String,
|
|
925
|
-
resolve: async function({ resolver: resolver4 }) {
|
|
926
|
-
const returns = isArray5(resolver4.returns) ? resolver4.returns[0] : resolver4.returns;
|
|
927
|
-
return await getBasicQuery({
|
|
928
|
-
type: resolverReturnsIsModel(returns) ? returns.getSchema() : ""
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
})
|
|
949
|
+
const schema = getSchemaFromAnyOrionForm2(field.type);
|
|
950
|
+
const fields = [];
|
|
951
|
+
for (const field2 of getStaticFields(schema)) {
|
|
952
|
+
fields.push(await getBasicQuery(field2));
|
|
932
953
|
}
|
|
933
|
-
}
|
|
954
|
+
const key = field.key ? `${field.key} ` : "";
|
|
955
|
+
return `${key}{ ${fields.join(" ")} }`;
|
|
956
|
+
}
|
|
934
957
|
|
|
935
958
|
// src/resolversSchemas/params.ts
|
|
936
|
-
|
|
959
|
+
function getResultTypeName(type) {
|
|
960
|
+
const returns = Array.isArray(type) ? type[0] : type;
|
|
961
|
+
const schema = getSchemaFromAnyOrionForm3(returns);
|
|
962
|
+
if (schema == null ? void 0 : schema.__modelName) return schema.__modelName;
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
async function getInternalBasicResultQuery(type) {
|
|
966
|
+
const returns = Array.isArray(type) ? type[0] : type;
|
|
967
|
+
if (isSchemaLike4(returns)) {
|
|
968
|
+
const schema = getSchemaFromAnyOrionForm3(returns);
|
|
969
|
+
return await getBasicQuery({
|
|
970
|
+
type: schema
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
return "";
|
|
974
|
+
}
|
|
975
|
+
var params_default = createResolver({
|
|
937
976
|
params: {
|
|
938
977
|
name: {
|
|
939
978
|
type: "ID"
|
|
@@ -944,18 +983,23 @@ var params_default = resolver2({
|
|
|
944
983
|
},
|
|
945
984
|
returns: ResolverParamsInfo_default,
|
|
946
985
|
mutation: false,
|
|
947
|
-
|
|
948
|
-
const
|
|
949
|
-
if (!
|
|
986
|
+
async resolve({ mutation, name }) {
|
|
987
|
+
const resolver2 = resolversStore[name];
|
|
988
|
+
if (!resolver2) {
|
|
950
989
|
throw new UserError(
|
|
951
990
|
"notFound",
|
|
952
991
|
`${mutation ? "Mutation" : "Query"} named "${name}" not found`
|
|
953
992
|
);
|
|
954
993
|
}
|
|
955
|
-
if (!!
|
|
994
|
+
if (!!resolver2.mutation !== !!mutation) {
|
|
956
995
|
throw new UserError("incorrectType", `"${name}" is ${mutation ? "not" : ""} a mutation`);
|
|
957
996
|
}
|
|
958
|
-
return {
|
|
997
|
+
return {
|
|
998
|
+
name,
|
|
999
|
+
basicResultQuery: await getInternalBasicResultQuery(resolver2.returns),
|
|
1000
|
+
params: await serializeSchema(resolver2.params),
|
|
1001
|
+
result: getResultTypeName(resolver2.returns)
|
|
1002
|
+
};
|
|
959
1003
|
}
|
|
960
1004
|
});
|
|
961
1005
|
|
|
@@ -978,79 +1022,107 @@ var OrionSubscription = class {
|
|
|
978
1022
|
|
|
979
1023
|
// src/service/global.ts
|
|
980
1024
|
import { getInstance, Service } from "@orion-js/services";
|
|
981
|
-
import { resolver
|
|
982
|
-
import { UserError as UserError2 } from "@orion-js/helpers";
|
|
1025
|
+
import { resolver } from "@orion-js/resolvers";
|
|
983
1026
|
|
|
984
|
-
// src/service/
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
};
|
|
997
|
-
};
|
|
1027
|
+
// src/service/middlewares.ts
|
|
1028
|
+
var resolversMetadata = /* @__PURE__ */ new WeakMap();
|
|
1029
|
+
function addTargetMetadata(target, propertyKey, metadataKey, metadata, isArray4 = false) {
|
|
1030
|
+
const targetMetadata = resolversMetadata.get(target) || {};
|
|
1031
|
+
targetMetadata[propertyKey] = targetMetadata[propertyKey] || {};
|
|
1032
|
+
if (isArray4) {
|
|
1033
|
+
targetMetadata[propertyKey][metadataKey] = targetMetadata[propertyKey][metadataKey] || [];
|
|
1034
|
+
targetMetadata[propertyKey][metadataKey].unshift(metadata);
|
|
1035
|
+
} else {
|
|
1036
|
+
targetMetadata[propertyKey][metadataKey] = metadata;
|
|
1037
|
+
}
|
|
1038
|
+
resolversMetadata.set(target, targetMetadata);
|
|
998
1039
|
}
|
|
999
1040
|
function getTargetMetadata(target, propertyKey, metadataKey) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1041
|
+
var _a;
|
|
1042
|
+
const targetMetadata = resolversMetadata.get(target) || {};
|
|
1043
|
+
return (_a = targetMetadata[propertyKey]) == null ? void 0 : _a[metadataKey];
|
|
1044
|
+
}
|
|
1045
|
+
function UseMiddleware(params) {
|
|
1046
|
+
return (method, context) => {
|
|
1047
|
+
const propertyKey = String(context.name);
|
|
1048
|
+
addTargetMetadata(method, propertyKey, "middlewares", params, true);
|
|
1049
|
+
return method;
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
function ResolverParams(params) {
|
|
1053
|
+
return (method, context) => {
|
|
1054
|
+
const propertyKey = String(context.name);
|
|
1055
|
+
addTargetMetadata(method, propertyKey, "params", params, false);
|
|
1056
|
+
return method;
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
function ResolverReturns(returns) {
|
|
1060
|
+
return (method, context) => {
|
|
1061
|
+
const propertyKey = String(context.name);
|
|
1062
|
+
addTargetMetadata(method, propertyKey, "returns", returns, false);
|
|
1063
|
+
return method;
|
|
1064
|
+
};
|
|
1002
1065
|
}
|
|
1003
|
-
var UseMiddleware = createRegisterResolverMetadata("middlewares", true);
|
|
1004
|
-
var ResolverParams = createRegisterResolverMetadata("params");
|
|
1005
|
-
var ResolverReturns = createRegisterResolverMetadata("returns");
|
|
1006
1066
|
|
|
1007
1067
|
// src/service/global.ts
|
|
1068
|
+
var serviceMetadata = /* @__PURE__ */ new WeakMap();
|
|
1069
|
+
var resolversMetadata2 = /* @__PURE__ */ new WeakMap();
|
|
1008
1070
|
function Resolvers() {
|
|
1009
|
-
return (target) => {
|
|
1010
|
-
Service()(target);
|
|
1011
|
-
|
|
1071
|
+
return (target, context) => {
|
|
1072
|
+
Service()(target, context);
|
|
1073
|
+
context.addInitializer(function() {
|
|
1074
|
+
serviceMetadata.set(this, { _serviceType: "resolvers" });
|
|
1075
|
+
});
|
|
1012
1076
|
};
|
|
1013
1077
|
}
|
|
1014
|
-
function Query(options) {
|
|
1015
|
-
return (
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1078
|
+
function Query(options = {}) {
|
|
1079
|
+
return (method, context) => {
|
|
1080
|
+
const propertyKey = String(context.name);
|
|
1081
|
+
context.addInitializer(function() {
|
|
1082
|
+
const resolvers = resolversMetadata2.get(this) || {};
|
|
1083
|
+
resolvers[propertyKey] = resolver({
|
|
1084
|
+
resolverId: propertyKey,
|
|
1085
|
+
params: getTargetMetadata(method, propertyKey, "params") || {},
|
|
1086
|
+
returns: getTargetMetadata(method, propertyKey, "returns") || "string",
|
|
1087
|
+
middlewares: getTargetMetadata(method, propertyKey, "middlewares") || [],
|
|
1088
|
+
...options,
|
|
1089
|
+
resolve: this[propertyKey].bind(this)
|
|
1090
|
+
});
|
|
1091
|
+
resolversMetadata2.set(this, resolvers);
|
|
1028
1092
|
});
|
|
1093
|
+
return method;
|
|
1029
1094
|
};
|
|
1030
1095
|
}
|
|
1031
1096
|
function Mutation(options) {
|
|
1032
|
-
return (
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1097
|
+
return (method, context) => {
|
|
1098
|
+
const propertyKey = String(context.name);
|
|
1099
|
+
context.addInitializer(function() {
|
|
1100
|
+
const resolvers = resolversMetadata2.get(this) || {};
|
|
1101
|
+
resolvers[propertyKey] = resolver({
|
|
1102
|
+
resolverId: propertyKey,
|
|
1103
|
+
params: getTargetMetadata(method, propertyKey, "params") || {},
|
|
1104
|
+
returns: getTargetMetadata(method, propertyKey, "returns") || "string",
|
|
1105
|
+
middlewares: getTargetMetadata(method, propertyKey, "middlewares") || [],
|
|
1106
|
+
...options,
|
|
1107
|
+
mutation: true,
|
|
1108
|
+
resolve: this[propertyKey].bind(this)
|
|
1109
|
+
});
|
|
1110
|
+
resolversMetadata2.set(this, resolvers);
|
|
1046
1111
|
});
|
|
1112
|
+
return method;
|
|
1047
1113
|
};
|
|
1048
1114
|
}
|
|
1049
1115
|
function getServiceResolvers(target) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1116
|
+
const instance = getInstance(target);
|
|
1117
|
+
if (!serviceMetadata.has(instance.constructor)) {
|
|
1118
|
+
throw new Error("You must pass a class decorated with @Resolvers to getServiceResolvers");
|
|
1119
|
+
}
|
|
1120
|
+
const instanceMetadata = serviceMetadata.get(instance.constructor);
|
|
1121
|
+
if (instanceMetadata._serviceType !== "resolvers") {
|
|
1122
|
+
throw new Error("You must pass a class decorated with @Resolvers to getServiceResolvers");
|
|
1052
1123
|
}
|
|
1053
|
-
|
|
1124
|
+
const resolversMap = resolversMetadata2.get(instance) || {};
|
|
1125
|
+
return resolversMap;
|
|
1054
1126
|
}
|
|
1055
1127
|
|
|
1056
1128
|
// src/service/model.ts
|
|
@@ -1058,82 +1130,105 @@ import { getInstance as getInstance2, Service as Service2 } from "@orion-js/serv
|
|
|
1058
1130
|
import {
|
|
1059
1131
|
modelResolver
|
|
1060
1132
|
} from "@orion-js/resolvers";
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
target
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1133
|
+
var serviceMetadata2 = /* @__PURE__ */ new WeakMap();
|
|
1134
|
+
var modelResolversMetadata = /* @__PURE__ */ new WeakMap();
|
|
1135
|
+
function ModelResolvers(typedSchema, options = {}) {
|
|
1136
|
+
return (target, context) => {
|
|
1137
|
+
Service2()(target, context);
|
|
1138
|
+
const modelName = options.modelName || typedSchema.name;
|
|
1139
|
+
context.addInitializer(function() {
|
|
1140
|
+
serviceMetadata2.set(this, {
|
|
1141
|
+
_serviceType: "modelResolvers",
|
|
1142
|
+
options,
|
|
1143
|
+
_typedSchema: typedSchema,
|
|
1144
|
+
_modelName: modelName
|
|
1145
|
+
});
|
|
1075
1146
|
});
|
|
1076
1147
|
};
|
|
1077
1148
|
}
|
|
1078
|
-
function
|
|
1079
|
-
return (
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1149
|
+
function ModelResolver(options) {
|
|
1150
|
+
return (method, context) => {
|
|
1151
|
+
const propertyKey = String(context.name);
|
|
1152
|
+
context.addInitializer(function() {
|
|
1153
|
+
const modelResolvers = modelResolversMetadata.get(this) || {};
|
|
1154
|
+
modelResolvers[propertyKey] = modelResolver({
|
|
1155
|
+
params: getTargetMetadata(method, propertyKey, "params") || {},
|
|
1156
|
+
returns: getTargetMetadata(method, propertyKey, "returns") || "string",
|
|
1157
|
+
middlewares: getTargetMetadata(method, propertyKey, "middlewares") || [],
|
|
1158
|
+
...options,
|
|
1159
|
+
resolve: this[propertyKey].bind(this)
|
|
1160
|
+
});
|
|
1161
|
+
modelResolversMetadata.set(this, modelResolvers);
|
|
1162
|
+
});
|
|
1163
|
+
return method;
|
|
1088
1164
|
};
|
|
1089
1165
|
}
|
|
1090
1166
|
function getServiceModelResolvers(target) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1167
|
+
const instance = getInstance2(target);
|
|
1168
|
+
if (!serviceMetadata2.has(instance.constructor)) {
|
|
1169
|
+
throw new Error(
|
|
1170
|
+
"You must pass a class decorated with @ModelResolvers to getServiceModelResolvers"
|
|
1171
|
+
);
|
|
1093
1172
|
}
|
|
1173
|
+
const instanceMetadata = serviceMetadata2.get(instance.constructor);
|
|
1174
|
+
if (instanceMetadata._serviceType !== "modelResolvers") {
|
|
1175
|
+
throw new Error(
|
|
1176
|
+
"You must pass a class decorated with @ModelResolvers to getServiceModelResolvers"
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
const modelResolversMap = modelResolversMetadata.get(instance) || {};
|
|
1094
1180
|
return {
|
|
1095
|
-
[
|
|
1181
|
+
[instanceMetadata._modelName]: modelResolversMap
|
|
1096
1182
|
};
|
|
1097
1183
|
}
|
|
1098
1184
|
|
|
1099
1185
|
// src/service/subscription.ts
|
|
1100
|
-
import {
|
|
1101
|
-
|
|
1186
|
+
import { getInstance as getInstance3, Service as Service3 } from "@orion-js/services";
|
|
1187
|
+
var serviceMetadata3 = /* @__PURE__ */ new WeakMap();
|
|
1188
|
+
var subscriptionsMetadata = /* @__PURE__ */ new WeakMap();
|
|
1102
1189
|
function Subscriptions() {
|
|
1103
|
-
return (target) => {
|
|
1104
|
-
Service3()(target);
|
|
1105
|
-
|
|
1106
|
-
|
|
1190
|
+
return (target, context) => {
|
|
1191
|
+
Service3()(target, context);
|
|
1192
|
+
context.addInitializer(function() {
|
|
1193
|
+
serviceMetadata3.set(this, { _serviceType: "subscriptions" });
|
|
1194
|
+
});
|
|
1107
1195
|
};
|
|
1108
1196
|
}
|
|
1109
1197
|
function Subscription(options) {
|
|
1110
|
-
return (
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
object,
|
|
1119
|
-
propertyName,
|
|
1120
|
-
index,
|
|
1121
|
-
value: (_containerInstance) => {
|
|
1122
|
-
if (!object.serviceType || object.serviceType !== "subscriptions") {
|
|
1123
|
-
throw new Error(
|
|
1124
|
-
"You must pass a class decorated with @Subscriptions if you want to use @Subscription"
|
|
1125
|
-
);
|
|
1126
|
-
}
|
|
1127
|
-
return sub;
|
|
1198
|
+
return (_target, context) => {
|
|
1199
|
+
const propertyKey = String(context.name);
|
|
1200
|
+
context.addInitializer(function() {
|
|
1201
|
+
const repo = serviceMetadata3.get(this.constructor);
|
|
1202
|
+
if (!repo || repo._serviceType !== "subscriptions") {
|
|
1203
|
+
throw new Error(
|
|
1204
|
+
"You must pass a class decorated with @Subscriptions if you want to use @Subscription"
|
|
1205
|
+
);
|
|
1128
1206
|
}
|
|
1207
|
+
const subscriptions = subscriptionsMetadata.get(this) || {};
|
|
1208
|
+
subscriptions[propertyKey] = subscription_default({
|
|
1209
|
+
name: propertyKey,
|
|
1210
|
+
...options
|
|
1211
|
+
});
|
|
1212
|
+
subscriptionsMetadata.set(this, subscriptions);
|
|
1213
|
+
this[propertyKey] = subscriptions[propertyKey];
|
|
1129
1214
|
});
|
|
1130
1215
|
};
|
|
1131
1216
|
}
|
|
1132
1217
|
function getServiceSubscriptions(target) {
|
|
1133
|
-
|
|
1134
|
-
|
|
1218
|
+
const instance = getInstance3(target);
|
|
1219
|
+
if (!serviceMetadata3.has(instance.constructor)) {
|
|
1220
|
+
throw new Error(
|
|
1221
|
+
"You must pass a class decorated with @Subscriptions to getServiceSubscriptions"
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
const instanceMetadata = serviceMetadata3.get(instance.constructor);
|
|
1225
|
+
if (instanceMetadata._serviceType !== "subscriptions") {
|
|
1226
|
+
throw new Error(
|
|
1227
|
+
"You must pass a class decorated with @Subscriptions to getServiceSubscriptions"
|
|
1228
|
+
);
|
|
1135
1229
|
}
|
|
1136
|
-
|
|
1230
|
+
const subscriptionsMap = subscriptionsMetadata.get(instance) || {};
|
|
1231
|
+
return subscriptionsMap;
|
|
1137
1232
|
}
|
|
1138
1233
|
export {
|
|
1139
1234
|
GraphQL2 as GraphQL,
|