1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var graphql_1 = require("graphql");
|
4 | var debugging_1 = require("../debugging");
|
5 | function isRequired(type) {
|
6 | var stringType = String(type);
|
7 | return stringType.lastIndexOf('!') === stringType.length - 1;
|
8 | }
|
9 | exports.isRequired = isRequired;
|
10 | function isNullable(type) {
|
11 | var stringType = String(type);
|
12 | return isArray(type) && !stringType.includes('!]');
|
13 | }
|
14 | exports.isNullable = isNullable;
|
15 | function isArray(type) {
|
16 | return String(type).indexOf('[') > -1;
|
17 | }
|
18 | exports.isArray = isArray;
|
19 | function dimensionOfArray(type) {
|
20 | if (isArray(type)) {
|
21 | var dimension = 0;
|
22 | var characters = Array.from(String(type));
|
23 | for (var _i = 0, characters_1 = characters; _i < characters_1.length; _i++) {
|
24 | var char = characters_1[_i];
|
25 | if (char !== '[') {
|
26 | return dimension;
|
27 | }
|
28 | else {
|
29 | dimension++;
|
30 | }
|
31 | }
|
32 | }
|
33 | return -1;
|
34 | }
|
35 | exports.dimensionOfArray = dimensionOfArray;
|
36 | function resolveType(type) {
|
37 | var name = graphql_1.getNamedType(type).name;
|
38 | debugging_1.debugLog("[resolveType] resolving type " + name);
|
39 | return {
|
40 | name: name,
|
41 | raw: String(type),
|
42 | isRequired: isRequired(type),
|
43 | isArray: isArray(type),
|
44 | isNullableArray: isNullable(type),
|
45 | dimensionOfArray: dimensionOfArray(type)
|
46 | };
|
47 | }
|
48 | exports.resolveType = resolveType;
|
49 |
|
\ | No newline at end of file |