source.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.Source = void 0;
  6. var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
  7. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * A representation of source input to GraphQL.
  11. * `name` and `locationOffset` are optional. They are useful for clients who
  12. * store GraphQL documents in source files; for example, if the GraphQL input
  13. * starts at line 40 in a file named Foo.graphql, it might be useful for name to
  14. * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
  15. * line and column in locationOffset are 1-indexed
  16. */
  17. var Source = function Source(body, name, locationOffset) {
  18. this.body = body;
  19. this.name = name || 'GraphQL request';
  20. this.locationOffset = locationOffset || {
  21. line: 1,
  22. column: 1
  23. };
  24. this.locationOffset.line > 0 || (0, _devAssert.default)(0, 'line in locationOffset is 1-indexed and must be positive');
  25. this.locationOffset.column > 0 || (0, _devAssert.default)(0, 'column in locationOffset is 1-indexed and must be positive');
  26. }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  27. exports.Source = Source;
  28. (0, _defineToStringTag.default)(Source);