predicates.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isDefinitionNode = isDefinitionNode;
  6. exports.isExecutableDefinitionNode = isExecutableDefinitionNode;
  7. exports.isSelectionNode = isSelectionNode;
  8. exports.isValueNode = isValueNode;
  9. exports.isTypeNode = isTypeNode;
  10. exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode;
  11. exports.isTypeDefinitionNode = isTypeDefinitionNode;
  12. exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode;
  13. exports.isTypeExtensionNode = isTypeExtensionNode;
  14. var _kinds = require("./kinds");
  15. function isDefinitionNode(node) {
  16. return isExecutableDefinitionNode(node) || isTypeSystemDefinitionNode(node) || isTypeSystemExtensionNode(node);
  17. }
  18. function isExecutableDefinitionNode(node) {
  19. return node.kind === _kinds.Kind.OPERATION_DEFINITION || node.kind === _kinds.Kind.FRAGMENT_DEFINITION;
  20. }
  21. function isSelectionNode(node) {
  22. return node.kind === _kinds.Kind.FIELD || node.kind === _kinds.Kind.FRAGMENT_SPREAD || node.kind === _kinds.Kind.INLINE_FRAGMENT;
  23. }
  24. function isValueNode(node) {
  25. return node.kind === _kinds.Kind.VARIABLE || node.kind === _kinds.Kind.INT || node.kind === _kinds.Kind.FLOAT || node.kind === _kinds.Kind.STRING || node.kind === _kinds.Kind.BOOLEAN || node.kind === _kinds.Kind.NULL || node.kind === _kinds.Kind.ENUM || node.kind === _kinds.Kind.LIST || node.kind === _kinds.Kind.OBJECT;
  26. }
  27. function isTypeNode(node) {
  28. return node.kind === _kinds.Kind.NAMED_TYPE || node.kind === _kinds.Kind.LIST_TYPE || node.kind === _kinds.Kind.NON_NULL_TYPE;
  29. }
  30. function isTypeSystemDefinitionNode(node) {
  31. return node.kind === _kinds.Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === _kinds.Kind.DIRECTIVE_DEFINITION;
  32. }
  33. function isTypeDefinitionNode(node) {
  34. return node.kind === _kinds.Kind.SCALAR_TYPE_DEFINITION || node.kind === _kinds.Kind.OBJECT_TYPE_DEFINITION || node.kind === _kinds.Kind.INTERFACE_TYPE_DEFINITION || node.kind === _kinds.Kind.UNION_TYPE_DEFINITION || node.kind === _kinds.Kind.ENUM_TYPE_DEFINITION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION;
  35. }
  36. function isTypeSystemExtensionNode(node) {
  37. return node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
  38. }
  39. function isTypeExtensionNode(node) {
  40. return node.kind === _kinds.Kind.SCALAR_TYPE_EXTENSION || node.kind === _kinds.Kind.OBJECT_TYPE_EXTENSION || node.kind === _kinds.Kind.INTERFACE_TYPE_EXTENSION || node.kind === _kinds.Kind.UNION_TYPE_EXTENSION || node.kind === _kinds.Kind.ENUM_TYPE_EXTENSION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION;
  41. }