schemaIsSubgraph.js 775 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.schemaIsSubgraph = void 0;
  4. const graphql_1 = require("graphql");
  5. function schemaIsSubgraph(schema) {
  6. const serviceType = schema.getType('_Service');
  7. if (!(0, graphql_1.isObjectType)(serviceType)) {
  8. return false;
  9. }
  10. const sdlField = serviceType.getFields().sdl;
  11. if (!sdlField) {
  12. return false;
  13. }
  14. let sdlFieldType = sdlField.type;
  15. if ((0, graphql_1.isNonNullType)(sdlFieldType)) {
  16. sdlFieldType = sdlFieldType.ofType;
  17. }
  18. if (!(0, graphql_1.isScalarType)(sdlFieldType)) {
  19. return false;
  20. }
  21. return sdlFieldType.name == 'String';
  22. }
  23. exports.schemaIsSubgraph = schemaIsSubgraph;
  24. //# sourceMappingURL=schemaIsSubgraph.js.map