forEachField.js 723 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.forEachField = void 0;
  4. const graphql_1 = require("graphql");
  5. function 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. }
  19. exports.forEachField = forEachField;