@orion-js/graphql 3.3.6 → 3.3.9
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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 getResolvers_1 = __importDefault(require("../getResolvers"));
|
|
18
|
+
const schema_1 = require("@orion-js/schema");
|
|
19
|
+
describe('Enum test', () => {
|
|
20
|
+
it('Should create correctly enum types', async () => {
|
|
21
|
+
const colorsEnum = (0, schema_1.createEnum)('ColorsEnum', ['red', 'blue', 'green']);
|
|
22
|
+
let TestParams = class TestParams {
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typed_model_1.Prop)({ type: colorsEnum }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], TestParams.prototype, "color", void 0);
|
|
28
|
+
TestParams = __decorate([
|
|
29
|
+
(0, typed_model_1.TypedSchema)()
|
|
30
|
+
], TestParams);
|
|
31
|
+
const globalResolver = (0, resolvers_1.resolver)({
|
|
32
|
+
params: TestParams,
|
|
33
|
+
returns: colorsEnum,
|
|
34
|
+
async resolve(params) {
|
|
35
|
+
return params.color;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const resolvers = { globalResolver };
|
|
39
|
+
const mutation = false;
|
|
40
|
+
const options = { resolvers };
|
|
41
|
+
const schema = await (0, getResolvers_1.default)(options, false);
|
|
42
|
+
expect(schema.globalResolver.args).toHaveProperty('color');
|
|
43
|
+
expect(schema.globalResolver.args.color.type.toString()).toEqual('ColorsEnum');
|
|
44
|
+
expect(schema.globalResolver.type.toString()).toEqual('ColorsEnum');
|
|
45
|
+
expect(await schema.globalResolver.resolve(null, { color: 'red' })).toEqual('red');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
23
|
};
|
|
@@ -6,15 +25,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
25
|
const BigIntScalar_1 = __importDefault(require("./BigIntScalar"));
|
|
7
26
|
const DateScalar_1 = __importDefault(require("./DateScalar"));
|
|
8
27
|
const JSONScalar_1 = __importDefault(require("./JSONScalar"));
|
|
9
|
-
const
|
|
28
|
+
const GraphQL = __importStar(require("graphql"));
|
|
29
|
+
const { GraphQLFloat, GraphQLString, GraphQLID, GraphQLBoolean } = GraphQL;
|
|
10
30
|
const fieldMap = {
|
|
11
|
-
string:
|
|
12
|
-
email:
|
|
31
|
+
string: GraphQLString,
|
|
32
|
+
email: GraphQLString,
|
|
13
33
|
date: DateScalar_1.default,
|
|
14
34
|
integer: BigIntScalar_1.default,
|
|
15
|
-
number:
|
|
16
|
-
ID:
|
|
17
|
-
boolean:
|
|
35
|
+
number: GraphQLFloat,
|
|
36
|
+
ID: GraphQLID,
|
|
37
|
+
boolean: GraphQLBoolean,
|
|
18
38
|
blackbox: JSONScalar_1.default
|
|
19
39
|
};
|
|
20
40
|
function default_1(fieldType) {
|
|
@@ -22,7 +42,7 @@ function default_1(fieldType) {
|
|
|
22
42
|
return fieldMap[fieldType.name];
|
|
23
43
|
}
|
|
24
44
|
if (fieldType.toGraphQLType) {
|
|
25
|
-
const result = fieldType.toGraphQLType();
|
|
45
|
+
const result = fieldType.toGraphQLType(GraphQL);
|
|
26
46
|
if (result.then) {
|
|
27
47
|
throw new Error('toGraphQLType cant return a promise');
|
|
28
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/graphql",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@orion-js/helpers": "^3.3.6",
|
|
17
|
-
"@orion-js/http": "^3.3.
|
|
18
|
-
"@orion-js/models": "^3.3.
|
|
19
|
-
"@orion-js/resolvers": "^3.3.
|
|
20
|
-
"@orion-js/schema": "^3.3.
|
|
17
|
+
"@orion-js/http": "^3.3.9",
|
|
18
|
+
"@orion-js/models": "^3.3.9",
|
|
19
|
+
"@orion-js/resolvers": "^3.3.9",
|
|
20
|
+
"@orion-js/schema": "^3.3.9",
|
|
21
21
|
"@orion-js/services": "^3.3.6",
|
|
22
|
-
"@orion-js/typed-model": "^3.3.
|
|
22
|
+
"@orion-js/typed-model": "^3.3.9",
|
|
23
23
|
"apollo-server-core": "3.5.0",
|
|
24
24
|
"graphql-iso-date": "^3.6.1",
|
|
25
25
|
"graphql-subscriptions": "^2.0.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c9591d61fe15eb98c6b6d5c3773afab11c412e42"
|
|
49
49
|
}
|