source.mjs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 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); } }
  2. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3. import { SYMBOL_TO_STRING_TAG } from "../polyfills/symbols.mjs";
  4. import devAssert from "../jsutils/devAssert.mjs";
  5. /**
  6. * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
  7. * optional, but they are useful for clients who store GraphQL documents in source files.
  8. * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
  9. * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
  10. * The `line` and `column` properties in `locationOffset` are 1-indexed.
  11. */
  12. export var Source = /*#__PURE__*/function () {
  13. function Source(body) {
  14. var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
  15. var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  16. line: 1,
  17. column: 1
  18. };
  19. this.body = body;
  20. this.name = name;
  21. this.locationOffset = locationOffset;
  22. this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
  23. this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
  24. } // $FlowFixMe Flow doesn't support computed properties yet
  25. _createClass(Source, [{
  26. key: SYMBOL_TO_STRING_TAG,
  27. get: function get() {
  28. return 'Source';
  29. }
  30. }]);
  31. return Source;
  32. }();