@omnigraph/json-schema 1.0.0-alpha-20220804093904-8e2e41f7f → 1.0.0-alpha-20230420220344-25b6b92bf
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/README.md +5 -4
- package/cjs/addExecutionLogicToComposer.js +208 -0
- package/cjs/addRootFieldResolver.js +395 -0
- package/cjs/bundle.js +65 -0
- package/cjs/directives.js +580 -0
- package/cjs/getComposerFromJSONSchema.js +1297 -0
- package/cjs/getDereferencedJSONSchemaFromOperations.js +33 -0
- package/cjs/getGraphQLSchemaFromDereferencedJSONSchema.js +39 -0
- package/cjs/getJSONSchemaStringFormatScalarMap.js +61 -0
- package/cjs/getReferencedJSONSchemaFromOperations.js +260 -0
- package/cjs/getTypeResolverFromOutputTCs.js +69 -0
- package/cjs/getUnionTypeComposers.js +85 -0
- package/cjs/getValidTypeName.js +20 -0
- package/cjs/index.js +14 -0
- package/cjs/loadGraphQLSchemaFromJSONSchemas.js +59 -0
- package/cjs/package.json +1 -0
- package/cjs/resolveDataByUnionInputType.js +40 -0
- package/cjs/scalars.js +30 -0
- package/cjs/types.js +0 -0
- package/cjs/utils.js +65 -0
- package/esm/addExecutionLogicToComposer.js +204 -0
- package/esm/addRootFieldResolver.js +390 -0
- package/esm/bundle.js +60 -0
- package/esm/directives.js +565 -0
- package/esm/getComposerFromJSONSchema.js +1293 -0
- package/esm/getDereferencedJSONSchemaFromOperations.js +29 -0
- package/esm/getGraphQLSchemaFromDereferencedJSONSchema.js +35 -0
- package/esm/getJSONSchemaStringFormatScalarMap.js +56 -0
- package/esm/getReferencedJSONSchemaFromOperations.js +255 -0
- package/esm/getTypeResolverFromOutputTCs.js +65 -0
- package/esm/getUnionTypeComposers.js +80 -0
- package/esm/getValidTypeName.js +16 -0
- package/esm/index.js +9 -0
- package/esm/loadGraphQLSchemaFromJSONSchemas.js +54 -0
- package/esm/resolveDataByUnionInputType.js +36 -0
- package/esm/scalars.js +27 -0
- package/esm/types.js +0 -0
- package/esm/utils.js +57 -0
- package/package.json +34 -27
- package/typings/addExecutionLogicToComposer.d.cts +14 -0
- package/typings/addExecutionLogicToComposer.d.ts +14 -0
- package/typings/addRootFieldResolver.d.cts +26 -0
- package/typings/addRootFieldResolver.d.ts +26 -0
- package/typings/bundle.d.cts +34 -0
- package/typings/bundle.d.ts +34 -0
- package/typings/directives.d.cts +54 -0
- package/typings/directives.d.ts +54 -0
- package/typings/getComposerFromJSONSchema.d.cts +13 -0
- package/{getComposerFromJSONSchema.d.ts → typings/getComposerFromJSONSchema.d.ts} +4 -1
- package/typings/getDereferencedJSONSchemaFromOperations.d.cts +14 -0
- package/{getDereferencedJSONSchemaFromOperations.d.ts → typings/getDereferencedJSONSchemaFromOperations.d.ts} +5 -3
- package/typings/getGraphQLSchemaFromDereferencedJSONSchema.d.cts +5 -0
- package/typings/getGraphQLSchemaFromDereferencedJSONSchema.d.ts +5 -0
- package/typings/getJSONSchemaStringFormatScalarMap.d.cts +2 -0
- package/typings/getJSONSchemaStringFormatScalarMap.d.ts +2 -0
- package/typings/getReferencedJSONSchemaFromOperations.d.cts +16 -0
- package/{getReferencedJSONSchemaFromOperations.d.ts → typings/getReferencedJSONSchemaFromOperations.d.ts} +6 -4
- package/typings/getTypeResolverFromOutputTCs.d.cts +7 -0
- package/typings/getTypeResolverFromOutputTCs.d.ts +7 -0
- package/typings/getUnionTypeComposers.d.cts +24 -0
- package/typings/getUnionTypeComposers.d.ts +24 -0
- package/{getStringScalarWithMinMaxLength.d.ts → typings/getValidTypeName.d.cts} +4 -3
- package/typings/index.d.cts +9 -0
- package/typings/index.d.ts +9 -0
- package/typings/loadGraphQLSchemaFromJSONSchemas.d.cts +3 -0
- package/typings/loadGraphQLSchemaFromJSONSchemas.d.ts +3 -0
- package/typings/resolveDataByUnionInputType.d.cts +2 -0
- package/typings/resolveDataByUnionInputType.d.ts +2 -0
- package/typings/scalars.d.cts +4 -0
- package/typings/scalars.d.ts +4 -0
- package/typings/types.d.cts +76 -0
- package/typings/types.d.ts +76 -0
- package/typings/utils.d.cts +15 -0
- package/{utils.d.ts → typings/utils.d.ts} +1 -1
- package/addExecutionLogicToComposer.d.ts +0 -15
- package/bundle.d.ts +0 -39
- package/getGenericJSONScalar.d.ts +0 -8
- package/getGraphQLSchemaFromDereferencedJSONSchema.d.ts +0 -3
- package/getJSONSchemaStringFormatScalarMap.d.ts +0 -3
- package/getTypeResolverFromOutputTCs.d.ts +0 -4
- package/getUnionTypeComposers.d.ts +0 -17
- package/getValidateFnForSchemaPath.d.ts +0 -3
- package/index.d.ts +0 -9
- package/index.js +0 -1908
- package/index.mjs +0 -1895
- package/loadGraphQLSchemaFromJSONSchemas.d.ts +0 -2
- package/resolveDataByUnionInputType.d.ts +0 -3
- package/types.d.ts +0 -62
- package/{getValidTypeName.d.ts → typings/getValidTypeName.d.ts} +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDataByUnionInputType = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const utils_1 = require("@graphql-mesh/utils");
|
|
6
|
+
const utils_2 = require("@graphql-tools/utils");
|
|
7
|
+
function resolveDataByUnionInputType(data, type, schema) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (data) {
|
|
10
|
+
if ((0, graphql_1.isListType)(type)) {
|
|
11
|
+
return (0, utils_2.asArray)(data).map(elem => resolveDataByUnionInputType(elem, type.ofType, schema));
|
|
12
|
+
}
|
|
13
|
+
if ((0, graphql_1.isNonNullType)(type)) {
|
|
14
|
+
return resolveDataByUnionInputType(data, type.ofType, schema);
|
|
15
|
+
}
|
|
16
|
+
if ((0, graphql_1.isInputObjectType)(type)) {
|
|
17
|
+
const typeOneOfDirectives = (0, utils_2.getDirective)(schema, type, 'oneOf');
|
|
18
|
+
const isOneOf = typeOneOfDirectives === null || typeOneOfDirectives === void 0 ? void 0 : typeOneOfDirectives.length;
|
|
19
|
+
const fieldMap = type.getFields();
|
|
20
|
+
data = (0, utils_2.asArray)(data)[0];
|
|
21
|
+
for (const propertyName in data) {
|
|
22
|
+
const fieldName = (0, utils_1.sanitizeNameForGraphQL)(propertyName);
|
|
23
|
+
const field = fieldMap[fieldName];
|
|
24
|
+
if (field) {
|
|
25
|
+
if (isOneOf) {
|
|
26
|
+
const resolvedData = resolveDataByUnionInputType(data[fieldName], field.type, schema);
|
|
27
|
+
return resolvedData;
|
|
28
|
+
}
|
|
29
|
+
const fieldData = data[fieldName];
|
|
30
|
+
data[fieldName] = undefined;
|
|
31
|
+
const fieldResolveRootFieldDirectives = (0, utils_2.getDirective)(schema, field, 'resolveRootField');
|
|
32
|
+
const realFieldName = ((_a = fieldResolveRootFieldDirectives === null || fieldResolveRootFieldDirectives === void 0 ? void 0 : fieldResolveRootFieldDirectives[0]) === null || _a === void 0 ? void 0 : _a.field) || fieldName;
|
|
33
|
+
data[realFieldName] = resolveDataByUnionInputType(fieldData, field.type, schema);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
exports.resolveDataByUnionInputType = resolveDataByUnionInputType;
|
package/cjs/scalars.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjMapScalar = exports.GraphQLVoid = exports.GraphQLFile = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
exports.GraphQLFile = new graphql_1.GraphQLScalarType({
|
|
6
|
+
name: 'File',
|
|
7
|
+
description: 'The `File` scalar type represents a file upload.',
|
|
8
|
+
extensions: {
|
|
9
|
+
codegenScalarType: 'File',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
exports.GraphQLVoid = new graphql_1.GraphQLScalarType({
|
|
13
|
+
name: 'Void',
|
|
14
|
+
description: 'Represents empty values',
|
|
15
|
+
serialize: () => '',
|
|
16
|
+
extensions: {
|
|
17
|
+
codegenScalarType: 'void',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
exports.ObjMapScalar = new graphql_1.GraphQLScalarType({
|
|
21
|
+
name: 'ObjMap',
|
|
22
|
+
serialize: value => JSON.stringify(value),
|
|
23
|
+
parseValue: value => JSON.parse(value.toString()),
|
|
24
|
+
parseLiteral: ast => {
|
|
25
|
+
if (ast.kind === 'StringValue') {
|
|
26
|
+
return JSON.parse(ast.value);
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
});
|
package/cjs/types.js
ADDED
|
File without changes
|
package/cjs/utils.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFile = exports.isFileUpload = exports.cleanObject = exports.getOperationMetadata = exports.isPubSubOperationConfig = void 0;
|
|
4
|
+
function isPubSubOperationConfig(operationConfig) {
|
|
5
|
+
return 'pubsubTopic' in operationConfig;
|
|
6
|
+
}
|
|
7
|
+
exports.isPubSubOperationConfig = isPubSubOperationConfig;
|
|
8
|
+
function getOperationMetadata(operationConfig) {
|
|
9
|
+
let httpMethod;
|
|
10
|
+
let operationType;
|
|
11
|
+
let rootTypeName;
|
|
12
|
+
if (isPubSubOperationConfig(operationConfig)) {
|
|
13
|
+
httpMethod = null;
|
|
14
|
+
operationType = 'subscription';
|
|
15
|
+
rootTypeName = 'Subscription';
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
httpMethod = operationConfig.method;
|
|
19
|
+
// Fix compability with Mesh handler
|
|
20
|
+
operationType = operationConfig.type.toLowerCase();
|
|
21
|
+
if (!httpMethod) {
|
|
22
|
+
if (operationType === 'mutation') {
|
|
23
|
+
httpMethod = 'POST';
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
httpMethod = 'GET';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!rootTypeName) {
|
|
30
|
+
if (httpMethod === 'GET') {
|
|
31
|
+
rootTypeName = 'Query';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
rootTypeName = operationType === 'query' ? 'Query' : 'Mutation';
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
httpMethod,
|
|
38
|
+
operationType,
|
|
39
|
+
rootTypeName,
|
|
40
|
+
fieldName: operationConfig.field,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.getOperationMetadata = getOperationMetadata;
|
|
44
|
+
function cleanObject(obj) {
|
|
45
|
+
if (typeof obj === 'object' && obj != null) {
|
|
46
|
+
const newObj = Array.isArray(obj) ? [] : {};
|
|
47
|
+
for (const key in obj) {
|
|
48
|
+
const newObjForKey = cleanObject(obj[key]);
|
|
49
|
+
if (newObjForKey != null) {
|
|
50
|
+
newObj[key] = newObjForKey;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
54
|
+
}
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
57
|
+
exports.cleanObject = cleanObject;
|
|
58
|
+
function isFileUpload(obj) {
|
|
59
|
+
return typeof obj.createReadStream === 'function';
|
|
60
|
+
}
|
|
61
|
+
exports.isFileUpload = isFileUpload;
|
|
62
|
+
function isFile(obj) {
|
|
63
|
+
return typeof obj.arrayBuffer === 'function';
|
|
64
|
+
}
|
|
65
|
+
exports.isFile = isFile;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { getNamedType, GraphQLInt, GraphQLObjectType, GraphQLString } from 'graphql';
|
|
2
|
+
import { GraphQLJSON, } from 'graphql-compose';
|
|
3
|
+
import { process } from '@graphql-mesh/cross-helpers';
|
|
4
|
+
import { GlobalOptionsDirective, HTTPOperationDirective, LinkDirective, LinkResolverDirective, PubSubOperationDirective, ResolveRootDirective, ResponseMetadataDirective, } from './directives.js';
|
|
5
|
+
import { getOperationMetadata, isPubSubOperationConfig } from './utils.js';
|
|
6
|
+
const responseMetadataType = new GraphQLObjectType({
|
|
7
|
+
name: 'ResponseMetadata',
|
|
8
|
+
fields: {
|
|
9
|
+
url: { type: GraphQLString },
|
|
10
|
+
method: { type: GraphQLString },
|
|
11
|
+
status: { type: GraphQLInt },
|
|
12
|
+
statusText: { type: GraphQLString },
|
|
13
|
+
headers: { type: GraphQLJSON },
|
|
14
|
+
body: { type: GraphQLJSON },
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
export async function addExecutionDirectivesToComposer(name, { schemaComposer, logger, operations, operationHeaders, endpoint, queryParams, queryStringOptions, }) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
schemaComposer.addDirective(GlobalOptionsDirective);
|
|
20
|
+
schemaComposer.Query.setDirectiveByName('globalOptions', JSON.parse(JSON.stringify({
|
|
21
|
+
sourceName: name,
|
|
22
|
+
endpoint,
|
|
23
|
+
operationHeaders,
|
|
24
|
+
queryStringOptions,
|
|
25
|
+
queryParams,
|
|
26
|
+
})));
|
|
27
|
+
logger.debug(`Attaching execution directives to the schema`);
|
|
28
|
+
for (const operationConfig of operations) {
|
|
29
|
+
const { httpMethod, rootTypeName, fieldName } = getOperationMetadata(operationConfig);
|
|
30
|
+
const rootTypeComposer = schemaComposer[rootTypeName];
|
|
31
|
+
const field = rootTypeComposer.getField(fieldName);
|
|
32
|
+
if (isPubSubOperationConfig(operationConfig)) {
|
|
33
|
+
field.description =
|
|
34
|
+
operationConfig.description || `PubSub Topic: ${operationConfig.pubsubTopic}`;
|
|
35
|
+
field.directives = field.directives || [];
|
|
36
|
+
schemaComposer.addDirective(PubSubOperationDirective);
|
|
37
|
+
field.directives.push({
|
|
38
|
+
name: 'pubsubOperation',
|
|
39
|
+
args: {
|
|
40
|
+
pubsubTopic: operationConfig.pubsubTopic,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (operationConfig.path) {
|
|
45
|
+
if (process.env.DEBUG === '1' || process.env.DEBUG === 'fieldDetails') {
|
|
46
|
+
field.description = `
|
|
47
|
+
>**Method**: \`${operationConfig.method}\`
|
|
48
|
+
>**Base URL**: \`${endpoint}\`
|
|
49
|
+
>**Path**: \`${operationConfig.path}\`
|
|
50
|
+
${operationConfig.description || ''}
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
field.description = operationConfig.description;
|
|
55
|
+
}
|
|
56
|
+
field.directives = field.directives || [];
|
|
57
|
+
schemaComposer.addDirective(HTTPOperationDirective);
|
|
58
|
+
field.directives.push({
|
|
59
|
+
name: 'httpOperation',
|
|
60
|
+
args: JSON.parse(JSON.stringify({
|
|
61
|
+
path: operationConfig.path,
|
|
62
|
+
operationSpecificHeaders: operationConfig.headers,
|
|
63
|
+
httpMethod,
|
|
64
|
+
isBinary: 'binary' in operationConfig ? operationConfig.binary : undefined,
|
|
65
|
+
requestBaseBody: 'requestBaseBody' in operationConfig ? operationConfig.requestBaseBody : undefined,
|
|
66
|
+
queryParamArgMap: operationConfig.queryParamArgMap,
|
|
67
|
+
queryStringOptionsByParam: operationConfig.queryStringOptionsByParam,
|
|
68
|
+
})),
|
|
69
|
+
});
|
|
70
|
+
const handleLinkMap = (linkMap, typeTC) => {
|
|
71
|
+
for (const linkName in linkMap) {
|
|
72
|
+
typeTC.addFields({
|
|
73
|
+
[linkName]: () => {
|
|
74
|
+
const linkObj = linkMap[linkName];
|
|
75
|
+
field.directives = field.directives || [];
|
|
76
|
+
let linkResolverMapDirective = field.directives.find(d => d.name === 'linkResolver');
|
|
77
|
+
if (!linkResolverMapDirective) {
|
|
78
|
+
schemaComposer.addDirective(LinkResolverDirective);
|
|
79
|
+
linkResolverMapDirective = {
|
|
80
|
+
name: 'linkResolver',
|
|
81
|
+
args: {
|
|
82
|
+
linkResolverMap: {},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
field.directives.push(linkResolverMapDirective);
|
|
86
|
+
}
|
|
87
|
+
const linkResolverFieldMap = linkResolverMapDirective.args.linkResolverMap;
|
|
88
|
+
let targetField;
|
|
89
|
+
let fieldTypeName;
|
|
90
|
+
try {
|
|
91
|
+
targetField = schemaComposer.Query.getField(linkObj.fieldName);
|
|
92
|
+
fieldTypeName = 'Query';
|
|
93
|
+
}
|
|
94
|
+
catch (_a) {
|
|
95
|
+
try {
|
|
96
|
+
targetField = schemaComposer.Mutation.getField(linkObj.fieldName);
|
|
97
|
+
fieldTypeName = 'Mutation';
|
|
98
|
+
}
|
|
99
|
+
catch (_b) { }
|
|
100
|
+
}
|
|
101
|
+
if (!targetField) {
|
|
102
|
+
logger.debug(`Field ${linkObj.fieldName} not found in ${name} for link ${linkName}`);
|
|
103
|
+
}
|
|
104
|
+
linkResolverFieldMap[linkName] = {
|
|
105
|
+
linkObjArgs: linkObj.args,
|
|
106
|
+
targetTypeName: fieldTypeName,
|
|
107
|
+
targetFieldName: linkObj.fieldName,
|
|
108
|
+
};
|
|
109
|
+
schemaComposer.addDirective(LinkDirective);
|
|
110
|
+
return {
|
|
111
|
+
...targetField,
|
|
112
|
+
directives: [
|
|
113
|
+
{
|
|
114
|
+
name: 'link',
|
|
115
|
+
args: {
|
|
116
|
+
defaultRootType: rootTypeName,
|
|
117
|
+
defaultField: operationConfig.field,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
args: linkObj.args ? {} : targetField.args,
|
|
122
|
+
description: linkObj.description || targetField.description,
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
if ('links' in operationConfig) {
|
|
129
|
+
const typeTC = schemaComposer.getOTC(field.type.getTypeName());
|
|
130
|
+
handleLinkMap(operationConfig.links, typeTC);
|
|
131
|
+
}
|
|
132
|
+
if ('exposeResponseMetadata' in operationConfig && operationConfig.exposeResponseMetadata) {
|
|
133
|
+
const typeTC = schemaComposer.getOTC(field.type.getTypeName());
|
|
134
|
+
schemaComposer.addDirective(ResponseMetadataDirective);
|
|
135
|
+
typeTC.addFields({
|
|
136
|
+
_response: {
|
|
137
|
+
type: responseMetadataType,
|
|
138
|
+
directives: [
|
|
139
|
+
{
|
|
140
|
+
name: 'responseMetadata',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if ('responseByStatusCode' in operationConfig) {
|
|
147
|
+
const unionOrSingleTC = schemaComposer.getAnyTC(getNamedType(field.type.getType()));
|
|
148
|
+
const types = 'getTypes' in unionOrSingleTC ? unionOrSingleTC.getTypes() : [unionOrSingleTC];
|
|
149
|
+
const statusCodeOneOfIndexMap = {};
|
|
150
|
+
const directives = unionOrSingleTC.getDirectives();
|
|
151
|
+
for (const directive of directives) {
|
|
152
|
+
if (directive.name === 'statusCodeOneOfIndex') {
|
|
153
|
+
statusCodeOneOfIndexMap[(_a = directive.args) === null || _a === void 0 ? void 0 : _a.statusCode] = (_b = directive.args) === null || _b === void 0 ? void 0 : _b.oneOfIndex;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const statusCode in operationConfig.responseByStatusCode) {
|
|
157
|
+
const responseConfig = operationConfig.responseByStatusCode[statusCode];
|
|
158
|
+
if (responseConfig.links || responseConfig.exposeResponseMetadata) {
|
|
159
|
+
const typeTCThunked = types[statusCodeOneOfIndexMap[statusCode] || 0];
|
|
160
|
+
const originalName = typeTCThunked.getTypeName();
|
|
161
|
+
let typeTC = schemaComposer.getAnyTC(originalName);
|
|
162
|
+
if (!('addFieldArgs' in typeTC)) {
|
|
163
|
+
schemaComposer.addDirective(ResolveRootDirective);
|
|
164
|
+
typeTC = schemaComposer.createObjectTC({
|
|
165
|
+
name: `${operationConfig.field}_${statusCode}_response`,
|
|
166
|
+
fields: {
|
|
167
|
+
[originalName]: {
|
|
168
|
+
type: typeTC,
|
|
169
|
+
directives: [
|
|
170
|
+
{
|
|
171
|
+
name: 'resolveRoot',
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
// If it is a scalar or enum type, it cannot be a union type, so we can set it directly
|
|
178
|
+
types[0] = typeTC;
|
|
179
|
+
field.type = typeTC;
|
|
180
|
+
}
|
|
181
|
+
if (responseConfig.exposeResponseMetadata) {
|
|
182
|
+
schemaComposer.addDirective(ResponseMetadataDirective);
|
|
183
|
+
typeTC.addFields({
|
|
184
|
+
_response: {
|
|
185
|
+
type: responseMetadataType,
|
|
186
|
+
directives: [
|
|
187
|
+
{
|
|
188
|
+
name: 'responseMetadata',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (responseConfig.links) {
|
|
195
|
+
handleLinkMap(responseConfig.links, typeTC);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
logger.debug(`Building the executable schema.`);
|
|
203
|
+
return schemaComposer;
|
|
204
|
+
}
|