UNPKG

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