1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.forEachDefaultValue = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | function forEachDefaultValue(schema, fn) {
|
6 | const typeMap = schema.getTypeMap();
|
7 | for (const typeName in typeMap) {
|
8 | const type = typeMap[typeName];
|
9 | if (!(0, graphql_1.getNamedType)(type).name.startsWith('__')) {
|
10 | if ((0, graphql_1.isObjectType)(type)) {
|
11 | const fields = type.getFields();
|
12 | for (const fieldName in fields) {
|
13 | const field = fields[fieldName];
|
14 | for (const arg of field.args) {
|
15 | arg.defaultValue = fn(arg.type, arg.defaultValue);
|
16 | }
|
17 | }
|
18 | }
|
19 | else if ((0, graphql_1.isInputObjectType)(type)) {
|
20 | const fields = type.getFields();
|
21 | for (const fieldName in fields) {
|
22 | const field = fields[fieldName];
|
23 | field.defaultValue = fn(field.type, field.defaultValue);
|
24 | }
|
25 | }
|
26 | }
|
27 | }
|
28 | }
|
29 | exports.forEachDefaultValue = forEachDefaultValue;
|