source.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.Source = void 0;
  6. var _symbols = require("../polyfills/symbols");
  7. var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11. /**
  12. * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
  13. * optional, but they are useful for clients who store GraphQL documents in source files.
  14. * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
  15. * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
  16. * The `line` and `column` properties in `locationOffset` are 1-indexed.
  17. */
  18. var Source = /*#__PURE__*/function () {
  19. function Source(body) {
  20. var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
  21. var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  22. line: 1,
  23. column: 1
  24. };
  25. this.body = body;
  26. this.name = name;
  27. this.locationOffset = locationOffset;
  28. this.locationOffset.line > 0 || (0, _devAssert.default)(0, 'line in locationOffset is 1-indexed and must be positive.');
  29. this.locationOffset.column > 0 || (0, _devAssert.default)(0, 'column in locationOffset is 1-indexed and must be positive.');
  30. } // $FlowFixMe Flow doesn't support computed properties yet
  31. _createClass(Source, [{
  32. key: _symbols.SYMBOL_TO_STRING_TAG,
  33. get: function get() {
  34. return 'Source';
  35. }
  36. }]);
  37. return Source;
  38. }();
  39. exports.Source = Source;