UNPKG

723 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.forEachField = void 0;
4const graphql_1 = require("graphql");
5function forEachField(schema, fn) {
6 const typeMap = schema.getTypeMap();
7 for (const typeName in typeMap) {
8 const type = typeMap[typeName];
9 // TODO: maybe have an option to include these?
10 if (!(0, graphql_1.getNamedType)(type).name.startsWith('__') && (0, graphql_1.isObjectType)(type)) {
11 const fields = type.getFields();
12 for (const fieldName in fields) {
13 const field = fields[fieldName];
14 fn(field, typeName, fieldName);
15 }
16 }
17 }
18}
19exports.forEachField = forEachField;