@orion-js/graphql 3.11.15 → 4.0.0-alpha.2

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.
Files changed (122) hide show
  1. package/dist/index.cjs +107839 -0
  2. package/dist/index.d.ts +570 -0
  3. package/dist/index.js +107812 -0
  4. package/package.json +30 -21
  5. package/LICENSE +0 -21
  6. package/jest.config.js +0 -8
  7. package/lib/buildSchema/getArgs/getField.d.ts +0 -1
  8. package/lib/buildSchema/getArgs/getField.js +0 -49
  9. package/lib/buildSchema/getArgs/index.d.ts +0 -1
  10. package/lib/buildSchema/getArgs/index.js +0 -24
  11. package/lib/buildSchema/getMutation.d.ts +0 -3
  12. package/lib/buildSchema/getMutation.js +0 -18
  13. package/lib/buildSchema/getQuery.d.ts +0 -3
  14. package/lib/buildSchema/getQuery.js +0 -18
  15. package/lib/buildSchema/getResolvers/index.d.ts +0 -3
  16. package/lib/buildSchema/getResolvers/index.js +0 -43
  17. package/lib/buildSchema/getResolvers/index.test.d.ts +0 -1
  18. package/lib/buildSchema/getResolvers/index.test.js +0 -65
  19. package/lib/buildSchema/getResolvers/resolversStore.d.ts +0 -3
  20. package/lib/buildSchema/getResolvers/resolversStore.js +0 -5
  21. package/lib/buildSchema/getSubscription.d.ts +0 -3
  22. package/lib/buildSchema/getSubscription.js +0 -17
  23. package/lib/buildSchema/getSubscriptions/index.d.ts +0 -2
  24. package/lib/buildSchema/getSubscriptions/index.js +0 -26
  25. package/lib/buildSchema/getSubscriptions/index.test.d.ts +0 -1
  26. package/lib/buildSchema/getSubscriptions/index.test.js +0 -52
  27. package/lib/buildSchema/getType/BigIntScalar.d.ts +0 -3
  28. package/lib/buildSchema/getType/BigIntScalar.js +0 -35
  29. package/lib/buildSchema/getType/DateScalar.d.ts +0 -3
  30. package/lib/buildSchema/getType/DateScalar.js +0 -10
  31. package/lib/buildSchema/getType/JSONScalar.d.ts +0 -3
  32. package/lib/buildSchema/getType/JSONScalar.js +0 -42
  33. package/lib/buildSchema/getType/enum.test.d.ts +0 -1
  34. package/lib/buildSchema/getType/enum.test.js +0 -80
  35. package/lib/buildSchema/getType/getScalar.d.ts +0 -1
  36. package/lib/buildSchema/getType/getScalar.js +0 -58
  37. package/lib/buildSchema/getType/getTypeAsResolver.d.ts +0 -10
  38. package/lib/buildSchema/getType/getTypeAsResolver.js +0 -26
  39. package/lib/buildSchema/getType/index.d.ts +0 -2
  40. package/lib/buildSchema/getType/index.js +0 -86
  41. package/lib/buildSchema/index.d.ts +0 -3
  42. package/lib/buildSchema/index.js +0 -17
  43. package/lib/cleanResolvers.d.ts +0 -1
  44. package/lib/cleanResolvers.js +0 -8
  45. package/lib/errorHandler.d.ts +0 -1
  46. package/lib/errorHandler.js +0 -42
  47. package/lib/getApolloOptions/formatError.d.ts +0 -1
  48. package/lib/getApolloOptions/formatError.js +0 -14
  49. package/lib/getApolloOptions/index.d.ts +0 -3
  50. package/lib/getApolloOptions/index.js +0 -26
  51. package/lib/index.d.ts +0 -12
  52. package/lib/index.js +0 -51
  53. package/lib/pubsub.d.ts +0 -3
  54. package/lib/pubsub.js +0 -12
  55. package/lib/resolversSchemas/ResolverParamsInfo.d.ts +0 -9
  56. package/lib/resolversSchemas/ResolverParamsInfo.js +0 -47
  57. package/lib/resolversSchemas/getBasicResultQuery.d.ts +0 -1
  58. package/lib/resolversSchemas/getBasicResultQuery.js +0 -24
  59. package/lib/resolversSchemas/getDynamicFields.d.ts +0 -2
  60. package/lib/resolversSchemas/getDynamicFields.js +0 -19
  61. package/lib/resolversSchemas/getField.d.ts +0 -1
  62. package/lib/resolversSchemas/getField.js +0 -50
  63. package/lib/resolversSchemas/getField.test.d.ts +0 -1
  64. package/lib/resolversSchemas/getField.test.js +0 -56
  65. package/lib/resolversSchemas/getModelLoadedResolvers.d.ts +0 -3
  66. package/lib/resolversSchemas/getModelLoadedResolvers.js +0 -21
  67. package/lib/resolversSchemas/getStaticFields.d.ts +0 -3
  68. package/lib/resolversSchemas/getStaticFields.js +0 -20
  69. package/lib/resolversSchemas/index.d.ts +0 -7
  70. package/lib/resolversSchemas/index.js +0 -9
  71. package/lib/resolversSchemas/params.d.ts +0 -5
  72. package/lib/resolversSchemas/params.js +0 -31
  73. package/lib/resolversSchemas/params.test.d.ts +0 -1
  74. package/lib/resolversSchemas/params.test.js +0 -131
  75. package/lib/resolversSchemas/serializeSchema.d.ts +0 -2
  76. package/lib/resolversSchemas/serializeSchema.js +0 -22
  77. package/lib/resolversSchemas/serializeSchema.test.d.ts +0 -1
  78. package/lib/resolversSchemas/serializeSchema.test.js +0 -56
  79. package/lib/service/global.d.ts +0 -10
  80. package/lib/service/global.js +0 -60
  81. package/lib/service/index.d.ts +0 -4
  82. package/lib/service/index.js +0 -20
  83. package/lib/service/index.test.d.ts +0 -1
  84. package/lib/service/index.test.js +0 -63
  85. package/lib/service/middlewares.test.d.ts +0 -1
  86. package/lib/service/middlewares.test.js +0 -125
  87. package/lib/service/model.d.ts +0 -14
  88. package/lib/service/model.js +0 -48
  89. package/lib/service/model.test.d.ts +0 -1
  90. package/lib/service/model.test.js +0 -126
  91. package/lib/service/otherParams.d.ts +0 -7
  92. package/lib/service/otherParams.js +0 -28
  93. package/lib/service/subscription.d.ts +0 -6
  94. package/lib/service/subscription.js +0 -43
  95. package/lib/service/subscription.test.d.ts +0 -1
  96. package/lib/service/subscription.test.js +0 -55
  97. package/lib/startGraphQL.d.ts +0 -2
  98. package/lib/startGraphQL.js +0 -43
  99. package/lib/startGraphQL.test.d.ts +0 -1
  100. package/lib/startGraphQL.test.js +0 -414
  101. package/lib/startGraphiQL.d.ts +0 -3
  102. package/lib/startGraphiQL.js +0 -207
  103. package/lib/startWebsocket.d.ts +0 -11
  104. package/lib/startWebsocket.js +0 -48
  105. package/lib/startWebsocket.test.d.ts +0 -1
  106. package/lib/startWebsocket.test.js +0 -303
  107. package/lib/subscription/getChannelName.d.ts +0 -1
  108. package/lib/subscription/getChannelName.js +0 -9
  109. package/lib/subscription/getChannelName.test.d.ts +0 -1
  110. package/lib/subscription/getChannelName.test.js +0 -26
  111. package/lib/subscription/index.d.ts +0 -3
  112. package/lib/subscription/index.js +0 -34
  113. package/lib/types/index.d.ts +0 -3
  114. package/lib/types/index.js +0 -19
  115. package/lib/types/startGraphQL.d.ts +0 -41
  116. package/lib/types/startGraphQL.js +0 -2
  117. package/lib/types/subscription.d.ts +0 -15
  118. package/lib/types/subscription.js +0 -2
  119. package/lib/websockerViewer.d.ts +0 -2
  120. package/lib/websockerViewer.js +0 -20
  121. package/tsconfig.json +0 -20
  122. package/yarn-error.log +0 -3949
package/package.json CHANGED
@@ -1,28 +1,29 @@
1
1
  {
2
2
  "name": "@orion-js/graphql",
3
- "version": "3.11.15",
4
- "main": "lib/index.js",
3
+ "version": "4.0.0-alpha.2",
4
+ "main": "./dist/index.cjs",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "test": "jest",
8
+ "test": "bun test",
9
9
  "prepare": "yarn run build",
10
- "clean": "rm -rf ./lib",
11
- "build": "yarn run clean && tsc",
10
+ "clean": "rm -rf ./dist",
11
+ "build": "bun run build.ts",
12
12
  "watch": "tsc -w",
13
- "upgrade-interactive": "yarn upgrade-interactive"
13
+ "upgrade-interactive": "yarn upgrade-interactive",
14
+ "dev": "bun --watch src/index.ts"
14
15
  },
15
16
  "dependencies": {
16
17
  "@apollo/server": "^4.3.0",
17
18
  "@graphql-tools/schema": "^9.0.12",
18
- "@orion-js/env": "^3.11.8",
19
- "@orion-js/helpers": "^3.11.15",
20
- "@orion-js/http": "^3.11.15",
21
- "@orion-js/models": "^3.11.15",
22
- "@orion-js/resolvers": "^3.11.15",
23
- "@orion-js/schema": "^3.11.8",
24
- "@orion-js/services": "^3.11.15",
25
- "@orion-js/typed-model": "^3.11.15",
19
+ "@orion-js/env": "^4.0.0-alpha.2",
20
+ "@orion-js/helpers": "^4.0.0-alpha.2",
21
+ "@orion-js/http": "^4.0.0-alpha.2",
22
+ "@orion-js/models": "^4.0.0-alpha.2",
23
+ "@orion-js/resolvers": "^4.0.0-alpha.2",
24
+ "@orion-js/schema": "^4.0.0-alpha.2",
25
+ "@orion-js/services": "^4.0.0-alpha.2",
26
+ "@orion-js/typed-model": "^4.0.0-alpha.2",
26
27
  "graphql-iso-date": "^3.6.1",
27
28
  "graphql-subscriptions": "2.0.0",
28
29
  "graphql-ws": "^5.11.2",
@@ -32,18 +33,15 @@
32
33
  },
33
34
  "devDependencies": {
34
35
  "@apollo/client": "^3.7.3",
35
- "@types/jest": "^29.2.5",
36
36
  "@types/lodash": "4.14.191",
37
37
  "@types/supertest": "2.0.12",
38
38
  "@types/ws": "^8.5.4",
39
39
  "graphql": "^16.6.0",
40
- "jest": "29.3.1",
41
- "jest-websocket-mock": "^2.4.0",
42
40
  "reflect-metadata": "^0.1.13",
43
41
  "supertest": "^6.3.3",
44
42
  "superwstest": "^2.0.3",
45
- "ts-jest": "29.0.3",
46
- "typescript": "^4.9.4"
43
+ "typescript": "^5.4.5",
44
+ "@types/bun": "^1.2.4"
47
45
  },
48
46
  "peerDependencies": {
49
47
  "graphql": "^16.0.1"
@@ -51,5 +49,16 @@
51
49
  "publishConfig": {
52
50
  "access": "public"
53
51
  },
54
- "gitHead": "a5c95d9fd18f779c834644eb757928cdb840643c"
55
- }
52
+ "gitHead": "9fd28b6f6b348cebc9f0dc207805647969277372",
53
+ "type": "module",
54
+ "module": "./dist/index.js",
55
+ "types": "./dist/index.d.ts",
56
+ "exports": {
57
+ "types": "./dist/index.d.ts",
58
+ "import": "./dist/index.js",
59
+ "require": "./dist/index.cjs"
60
+ },
61
+ "files": [
62
+ "dist"
63
+ ]
64
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Orionjs Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/jest.config.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- roots: ['./src'],
3
- testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
4
- transform: {
5
- '^.+\\.(ts|tsx)$': 'ts-jest'
6
- },
7
- verbose: true
8
- }
@@ -1 +0,0 @@
1
- export default function getParams(type: any): any;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
7
- const isArray_1 = __importDefault(require("lodash/isArray"));
8
- const graphql_1 = require("graphql");
9
- const schema_1 = require("@orion-js/schema");
10
- const getScalar_1 = __importDefault(require("../getType/getScalar"));
11
- const getStaticFields_1 = require("../../resolversSchemas/getStaticFields");
12
- const storedModelInput = {};
13
- const getModelInput = function (model, fields) {
14
- if (storedModelInput[model.name]) {
15
- return storedModelInput[model.name];
16
- }
17
- storedModelInput[model.name] = new graphql_1.GraphQLInputObjectType({
18
- name: model.name + 'Input',
19
- fields
20
- });
21
- return storedModelInput[model.name];
22
- };
23
- function getParams(type) {
24
- if (!type) {
25
- throw new Error(`No type specified`);
26
- }
27
- if ((0, isArray_1.default)(type)) {
28
- const graphQLType = getParams(type[0]);
29
- return new graphql_1.GraphQLList(graphQLType);
30
- }
31
- else if (!type._isFieldType && ((0, isPlainObject_1.default)(type) || type.__isModel)) {
32
- const model = type.__isModel ? type : type.__model;
33
- if (!model || !model.__isModel)
34
- throw new Error(`A type is not a Model`);
35
- const fields = {};
36
- for (const field of (0, getStaticFields_1.getStaticFields)(model)) {
37
- fields[field.key] = {
38
- type: getParams(field.type)
39
- };
40
- }
41
- return getModelInput(model, fields);
42
- }
43
- else {
44
- const schemaType = (0, schema_1.getFieldType)(type);
45
- const graphQLType = (0, getScalar_1.default)(schemaType);
46
- return graphQLType;
47
- }
48
- }
49
- exports.default = getParams;
@@ -1 +0,0 @@
1
- export default function (params: any): {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const getField_1 = __importDefault(require("./getField"));
7
- function default_1(params) {
8
- if (!params)
9
- return;
10
- if (Object.keys(params).length === 0)
11
- return;
12
- const fields = {};
13
- for (const key of Object.keys(params)) {
14
- try {
15
- const type = (0, getField_1.default)(params[key].type);
16
- fields[key] = { type };
17
- }
18
- catch (error) {
19
- throw new Error(`Error creating GraphQL resolver params argument ${key}: ${error.message}`);
20
- }
21
- }
22
- return fields;
23
- }
24
- exports.default = default_1;
@@ -1,3 +0,0 @@
1
- import { GraphQLObjectType } from 'graphql';
2
- import { StartGraphQLOptions } from '../types/startGraphQL';
3
- export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType<any, any>>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const graphql_1 = require("graphql");
7
- const getResolvers_1 = __importDefault(require("./getResolvers"));
8
- const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
9
- async function default_1(options) {
10
- const fields = await (0, getResolvers_1.default)(options, true);
11
- if ((0, isEmpty_1.default)(fields))
12
- return null;
13
- return new graphql_1.GraphQLObjectType({
14
- name: 'Mutation',
15
- fields
16
- });
17
- }
18
- exports.default = default_1;
@@ -1,3 +0,0 @@
1
- import { GraphQLObjectType } from 'graphql';
2
- import { StartGraphQLOptions } from '../types/startGraphQL';
3
- export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType<any, any>>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const graphql_1 = require("graphql");
7
- const getResolvers_1 = __importDefault(require("./getResolvers"));
8
- const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
9
- async function default_1(options) {
10
- const fields = await (0, getResolvers_1.default)(options, false);
11
- if ((0, isEmpty_1.default)(fields))
12
- return null;
13
- return new graphql_1.GraphQLObjectType({
14
- name: 'Query',
15
- fields
16
- });
17
- }
18
- exports.default = default_1;
@@ -1,3 +0,0 @@
1
- import { GraphQLFieldConfig } from 'graphql';
2
- import { StartGraphQLOptions } from '../../types/startGraphQL';
3
- export default function (options: StartGraphQLOptions, mutation: boolean): Promise<import("graphql/jsutils/ObjMap").ObjMap<GraphQLFieldConfig<any, any, any>>>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const getType_1 = __importDefault(require("../getType"));
7
- const getArgs_1 = __importDefault(require("../getArgs"));
8
- const errorHandler_1 = __importDefault(require("../../errorHandler"));
9
- const resolversStore_1 = require("./resolversStore");
10
- async function default_1(options, mutation) {
11
- const { resolvers } = options;
12
- const filteredResolvers = Object.keys(resolvers)
13
- .map(key => {
14
- return {
15
- name: key,
16
- resolver: resolvers[key],
17
- };
18
- })
19
- .filter(({ resolver }) => !!resolver.mutation === !!mutation)
20
- .filter(({ resolver }) => !resolver.private);
21
- const fields = {};
22
- for (const { resolver, name } of filteredResolvers) {
23
- resolversStore_1.resolversStore[name] = resolver;
24
- const type = await (0, getType_1.default)(resolver.returns, options);
25
- const args = await (0, getArgs_1.default)(resolver.params);
26
- fields[name] = {
27
- type,
28
- args,
29
- async resolve(root, params, context, info) {
30
- try {
31
- const result = await resolver.resolve(params, context, info);
32
- return result;
33
- }
34
- catch (error) {
35
- (0, errorHandler_1.default)(error, { context, resolver, options, name });
36
- throw error;
37
- }
38
- },
39
- };
40
- }
41
- return fields;
42
- }
43
- exports.default = default_1;
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const resolvers_1 = require("@orion-js/resolvers");
16
- const typed_model_1 = require("@orion-js/typed-model");
17
- const index_1 = __importDefault(require("./index"));
18
- describe('Test get resolvers schema', () => {
19
- it('Should correctly build a resolvers schema using typed models', async () => {
20
- let TestParams = class TestParams {
21
- };
22
- __decorate([
23
- (0, typed_model_1.Prop)(),
24
- __metadata("design:type", String)
25
- ], TestParams.prototype, "userId", void 0);
26
- TestParams = __decorate([
27
- (0, typed_model_1.TypedModel)()
28
- ], TestParams);
29
- let TestModel = class TestModel {
30
- };
31
- __decorate([
32
- (0, typed_model_1.Prop)(),
33
- __metadata("design:type", String)
34
- ], TestModel.prototype, "name", void 0);
35
- __decorate([
36
- (0, typed_model_1.Prop)(),
37
- __metadata("design:type", Number)
38
- ], TestModel.prototype, "age", void 0);
39
- TestModel = __decorate([
40
- (0, typed_model_1.TypedModel)()
41
- ], TestModel);
42
- const globalResolver = (0, resolvers_1.resolver)({
43
- params: TestParams,
44
- returns: TestModel,
45
- async resolve(params) {
46
- return {
47
- userId: params.userId,
48
- name: 'test',
49
- age: 10,
50
- };
51
- },
52
- });
53
- const resolvers = { globalResolver };
54
- const mutation = false;
55
- const options = { resolvers };
56
- const schema = await (0, index_1.default)(options, mutation);
57
- expect(schema.globalResolver.type.toString()).toEqual('TestModel');
58
- expect(schema.globalResolver.args).toHaveProperty('userId');
59
- expect(await schema.globalResolver.resolve(null, { userId: '1' })).toEqual({
60
- userId: '1',
61
- name: 'test',
62
- age: 10,
63
- });
64
- });
65
- });
@@ -1,3 +0,0 @@
1
- import { GlobalResolversMap } from '@orion-js/models';
2
- declare const resolversStore: GlobalResolversMap;
3
- export { resolversStore };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolversStore = void 0;
4
- const resolversStore = {};
5
- exports.resolversStore = resolversStore;
@@ -1,3 +0,0 @@
1
- import { GraphQLObjectType } from 'graphql';
2
- import { StartGraphQLOptions } from '../types/startGraphQL';
3
- export default function (options: StartGraphQLOptions): Promise<GraphQLObjectType>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const graphql_1 = require("graphql");
7
- const getSubscriptions_1 = __importDefault(require("./getSubscriptions"));
8
- async function default_1(options) {
9
- if (!options.subscriptions)
10
- return null;
11
- const fields = await (0, getSubscriptions_1.default)(options);
12
- return new graphql_1.GraphQLObjectType({
13
- name: 'Subscription',
14
- fields
15
- });
16
- }
17
- exports.default = default_1;
@@ -1,2 +0,0 @@
1
- import { StartGraphQLOptions } from '../../types/startGraphQL';
2
- export default function (options: StartGraphQLOptions): Promise<{}>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const getType_1 = __importDefault(require("../getType"));
7
- const getArgs_1 = __importDefault(require("../getArgs"));
8
- async function default_1(options) {
9
- const { subscriptions } = options;
10
- const fields = {};
11
- for (const key of Object.keys(subscriptions)) {
12
- const subscription = subscriptions[key];
13
- subscription.name = subscription.name || key;
14
- const type = await (0, getType_1.default)(subscription.returns, options);
15
- const args = await (0, getArgs_1.default)(subscription.params);
16
- fields[subscription.name] = {
17
- type,
18
- args,
19
- async subscribe(root, params, viewer) {
20
- return await subscription.subscribe(params, viewer);
21
- }
22
- };
23
- }
24
- return fields;
25
- }
26
- exports.default = default_1;
@@ -1 +0,0 @@
1
- export {};
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const typed_model_1 = require("@orion-js/typed-model");
16
- const __1 = require("../..");
17
- const index_1 = __importDefault(require("./index"));
18
- describe('Test get subscriptions schema', () => {
19
- it('Should correctly build a subscriptions schema using typed models', async () => {
20
- let TestParams = class TestParams {
21
- };
22
- __decorate([
23
- (0, typed_model_1.Prop)(),
24
- __metadata("design:type", String)
25
- ], TestParams.prototype, "userId", void 0);
26
- TestParams = __decorate([
27
- (0, typed_model_1.TypedSchema)()
28
- ], TestParams);
29
- let TestModel = class TestModel {
30
- };
31
- __decorate([
32
- (0, typed_model_1.Prop)(),
33
- __metadata("design:type", String)
34
- ], TestModel.prototype, "name", void 0);
35
- __decorate([
36
- (0, typed_model_1.Prop)(),
37
- __metadata("design:type", Number)
38
- ], TestModel.prototype, "age", void 0);
39
- TestModel = __decorate([
40
- (0, typed_model_1.TypedSchema)()
41
- ], TestModel);
42
- const modelSub = (0, __1.subscription)({
43
- params: TestParams,
44
- returns: TestModel
45
- });
46
- const subscriptions = { modelSub };
47
- const options = { subscriptions, resolvers: {} };
48
- const schema = await (0, index_1.default)(options);
49
- expect(schema.modelSub.type.toString()).toEqual('TestModel');
50
- expect(schema.modelSub.args).toHaveProperty('userId');
51
- });
52
- });
@@ -1,3 +0,0 @@
1
- import { GraphQLScalarType } from 'graphql';
2
- declare const _default: GraphQLScalarType<number, number>;
3
- export default _default;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const graphql_1 = require("graphql");
4
- const MAX_INT = Number.MAX_SAFE_INTEGER;
5
- const MIN_INT = Number.MIN_SAFE_INTEGER;
6
- const coerceBigInt = function coerceBigInt(value) {
7
- if (value === '') {
8
- throw new TypeError('BigInt cannot represent non 53-bit signed integer value: (empty string)');
9
- }
10
- const num = Number(value);
11
- if (num > MAX_INT || num < MIN_INT) {
12
- throw new TypeError('BigInt cannot represent non 53-bit signed integer value: ' + String(value));
13
- }
14
- const int = Math.floor(num);
15
- if (int !== num) {
16
- throw new TypeError('BigInt cannot represent non-integer value: ' + String(value));
17
- }
18
- return int;
19
- };
20
- exports.default = new graphql_1.GraphQLScalarType({
21
- name: 'BigInt',
22
- description: 'The `BigInt` scalar type represents non-fractional signed whole numeric ' +
23
- 'values. BigInt can represent values between -(2^53) + 1 and 2^53 - 1. ',
24
- serialize: coerceBigInt,
25
- parseValue: coerceBigInt,
26
- parseLiteral(ast) {
27
- if (ast.kind === 'IntValue') {
28
- const num = parseInt(ast.value, 10);
29
- if (num <= MAX_INT && num >= MIN_INT) {
30
- return num;
31
- }
32
- }
33
- return null;
34
- }
35
- });
@@ -1,3 +0,0 @@
1
- import { GraphQLScalarType } from 'graphql';
2
- declare const _default: GraphQLScalarType<unknown, unknown>;
3
- export default _default;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const graphql_1 = require("graphql");
4
- const graphql_iso_date_1 = require("graphql-iso-date");
5
- exports.default = new graphql_1.GraphQLScalarType({
6
- name: 'Date',
7
- serialize: graphql_iso_date_1.GraphQLDateTime.serialize,
8
- parseValue: graphql_iso_date_1.GraphQLDateTime.parseValue,
9
- parseLiteral: graphql_iso_date_1.GraphQLDateTime.parseLiteral
10
- });
@@ -1,3 +0,0 @@
1
- import { GraphQLScalarType } from 'graphql';
2
- declare const _default: GraphQLScalarType<any, any>;
3
- export default _default;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const graphql_1 = require("graphql");
4
- function identity(value) {
5
- return value;
6
- }
7
- function parseLiteral(ast, variables) {
8
- switch (ast.kind) {
9
- case graphql_1.Kind.STRING:
10
- case graphql_1.Kind.BOOLEAN:
11
- return ast.value;
12
- case graphql_1.Kind.INT:
13
- case graphql_1.Kind.FLOAT:
14
- return parseFloat(ast.value);
15
- case graphql_1.Kind.OBJECT: {
16
- const value = Object.create(null);
17
- ast.fields.forEach(field => {
18
- value[field.name.value] = parseLiteral(field.value, variables);
19
- });
20
- return value;
21
- }
22
- case graphql_1.Kind.LIST:
23
- return ast.values.map(n => parseLiteral(n, variables));
24
- case graphql_1.Kind.NULL:
25
- return null;
26
- case graphql_1.Kind.VARIABLE: {
27
- const name = ast.name.value;
28
- return variables ? variables[name] : undefined;
29
- }
30
- default:
31
- return undefined;
32
- }
33
- }
34
- exports.default = new graphql_1.GraphQLScalarType({
35
- name: 'JSON',
36
- description: 'The `JSON` scalar type represents JSON values as specified by ' +
37
- '[ECMA-404](http://www.ecma-international.org/' +
38
- 'publications/files/ECMA-ST/ECMA-404.pdf).',
39
- serialize: identity,
40
- parseValue: identity,
41
- parseLiteral
42
- });
@@ -1 +0,0 @@
1
- export {};