@graphiql/plugin-query-builder 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/arg-input/arg-input-by-type.js +441 -444
  3. package/dist/components/arg-input/arg-input-by-type.js.map +1 -1
  4. package/dist/components/arg-input/enum-arg-control.js +49 -52
  5. package/dist/components/arg-input/enum-arg-control.js.map +1 -1
  6. package/dist/components/arg-input/index.js +44 -36
  7. package/dist/components/arg-input/index.js.map +1 -1
  8. package/dist/components/arg-input/scalar-arg-control.js +58 -63
  9. package/dist/components/arg-input/scalar-arg-control.js.map +1 -1
  10. package/dist/components/field-row.js +212 -197
  11. package/dist/components/field-row.js.map +1 -1
  12. package/dist/components/field-tree-context.js +23 -27
  13. package/dist/components/field-tree-context.js.map +1 -1
  14. package/dist/components/field-tree-node.js +128 -105
  15. package/dist/components/field-tree-node.js.map +1 -1
  16. package/dist/components/field-tree.js +178 -199
  17. package/dist/components/field-tree.js.map +1 -1
  18. package/dist/components/fragment-editor.js +157 -151
  19. package/dist/components/fragment-editor.js.map +1 -1
  20. package/dist/components/fragment-section.js +215 -203
  21. package/dist/components/fragment-section.js.map +1 -1
  22. package/dist/components/query-builder.js +205 -181
  23. package/dist/components/query-builder.js.map +1 -1
  24. package/dist/components/type-condition-selector.js +417 -462
  25. package/dist/components/type-condition-selector.js.map +1 -1
  26. package/dist/components/use-cursor-path.js +69 -70
  27. package/dist/components/use-cursor-path.js.map +1 -1
  28. package/dist/components/use-cursor-reveal.js +83 -89
  29. package/dist/components/use-cursor-reveal.js.map +1 -1
  30. package/dist/components/use-working-document.js +432 -527
  31. package/dist/components/use-working-document.js.map +1 -1
  32. package/dist/index.js +11 -11
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/arg-value.js +132 -139
  35. package/dist/lib/arg-value.js.map +1 -1
  36. package/dist/lib/arguments.js +54 -55
  37. package/dist/lib/arguments.js.map +1 -1
  38. package/dist/lib/ast-path.js +266 -291
  39. package/dist/lib/ast-path.js.map +1 -1
  40. package/dist/lib/field-list-view.js +33 -43
  41. package/dist/lib/field-list-view.js.map +1 -1
  42. package/dist/lib/field-selection.js +63 -67
  43. package/dist/lib/field-selection.js.map +1 -1
  44. package/dist/lib/fragments.js +166 -152
  45. package/dist/lib/fragments.js.map +1 -1
  46. package/dist/lib/inline-fragments.js +64 -62
  47. package/dist/lib/inline-fragments.js.map +1 -1
  48. package/dist/lib/schema-walk.js +141 -158
  49. package/dist/lib/schema-walk.js.map +1 -1
  50. package/dist/lib/variables.js +96 -90
  51. package/dist/lib/variables.js.map +1 -1
  52. package/dist/style.css +4 -22
  53. package/package.json +21 -18
@@ -1,330 +1,305 @@
1
1
  import { Kind } from "graphql";
2
+ //#region src/lib/ast-path.ts
2
3
  function fieldSegment(name) {
3
- return {
4
- kind: "field",
5
- name
6
- };
4
+ return {
5
+ kind: "field",
6
+ name
7
+ };
7
8
  }
9
+ /** Builds the path segment that addresses the `... on TypeName` inline fragment. */
8
10
  function inlineFragmentSegment(typeName) {
9
- return {
10
- kind: "inlineFragment",
11
- typeName
12
- };
11
+ return {
12
+ kind: "inlineFragment",
13
+ typeName
14
+ };
13
15
  }
14
16
  function segmentsEqual(a, b) {
15
- if (a.kind !== b.kind) {
16
- return false;
17
- }
18
- if (a.kind === "field" && b.kind === "field") {
19
- return a.name === b.name;
20
- }
21
- if (a.kind === "inlineFragment" && b.kind === "inlineFragment") {
22
- return a.typeName === b.typeName;
23
- }
24
- return false;
17
+ if (a.kind !== b.kind) return false;
18
+ if (a.kind === "field" && b.kind === "field") return a.name === b.name;
19
+ if (a.kind === "inlineFragment" && b.kind === "inlineFragment") return a.typeName === b.typeName;
20
+ return false;
25
21
  }
22
+ /**
23
+ * True when `selection` is the field or inline fragment named by `segment`.
24
+ *
25
+ * Fields are matched by schema name, not response key: the builder's tree is
26
+ * driven by the schema, so a path segment is a field name and never carries an
27
+ * alias. A document the user hand-aliased (`a: hero b: hero`) therefore matches
28
+ * the first selection with that name. Helpers that walk to a single node act
29
+ * on that first match only (see `mapNodeAtPath`), so unchecking an aliased
30
+ * field removes one occurrence rather than wiping every alias of it. Full
31
+ * alias-aware editing would require a selection-driven tree and is out of scope.
32
+ */
26
33
  function selectionMatchesSegment(selection, segment) {
27
- var _a;
28
- switch (segment.kind) {
29
- case "inlineFragment":
30
- return selection.kind === Kind.INLINE_FRAGMENT && ((_a = selection.typeCondition) == null ? void 0 : _a.name.value) === segment.typeName;
31
- case "field":
32
- return selection.kind === Kind.FIELD && selection.name.value === segment.name;
33
- }
34
+ switch (segment.kind) {
35
+ case "inlineFragment": return selection.kind === Kind.INLINE_FRAGMENT && selection.typeCondition?.name.value === segment.typeName;
36
+ case "field": return selection.kind === Kind.FIELD && selection.name.value === segment.name;
37
+ }
34
38
  }
39
+ /**
40
+ * Walks `path` through `selectionSet` via `selectionMatchesSegment` and
41
+ * returns the node at the final segment, or `undefined` if any segment is
42
+ * missing.
43
+ */
35
44
  function findNodeAtPath(selectionSet, path) {
36
- let current = selectionSet;
37
- for (let i = 0; i < path.length; i++) {
38
- const segment = path[i];
39
- const node = current.selections.find((s) => selectionMatchesSegment(s, segment));
40
- if (!node) {
41
- return void 0;
42
- }
43
- if (i === path.length - 1) {
44
- return node;
45
- }
46
- if (!node.selectionSet) {
47
- return void 0;
48
- }
49
- current = node.selectionSet;
50
- }
51
- return void 0;
45
+ let current = selectionSet;
46
+ for (let i = 0; i < path.length; i++) {
47
+ const segment = path[i];
48
+ const node = current.selections.find((s) => selectionMatchesSegment(s, segment));
49
+ if (!node) return;
50
+ if (i === path.length - 1) return node;
51
+ if (!node.selectionSet) return;
52
+ current = node.selectionSet;
53
+ }
52
54
  }
55
+ /**
56
+ * Immutably rebuilds `selectionSet`, descending to the node at `path` via
57
+ * `selectionMatchesSegment`, then applying `fn` to it. `fn` returns the
58
+ * replacement node, or `undefined` to delete it. When `pruneEmptyParent` is
59
+ * true (default), a non-leaf ancestor whose child selection set becomes empty
60
+ * after the operation is itself pruned. Returns the original `selectionSet`
61
+ * reference unchanged when `path` does not resolve.
62
+ */
53
63
  function mapNodeAtPath(selectionSet, path, fn, pruneEmptyParent = true) {
54
- const [segment, ...rest] = path;
55
- const nodeIndex = selectionSet.selections.findIndex((s) => selectionMatchesSegment(s, segment));
56
- if (nodeIndex === -1) {
57
- return selectionSet;
58
- }
59
- const node = selectionSet.selections[nodeIndex];
60
- if (rest.length === 0) {
61
- const replacement = fn(node);
62
- const newSelections2 = [...selectionSet.selections];
63
- if (replacement === null) {
64
- newSelections2.splice(nodeIndex, 1);
65
- } else {
66
- newSelections2[nodeIndex] = replacement;
67
- }
68
- return {
69
- ...selectionSet,
70
- selections: newSelections2
71
- };
72
- }
73
- if (!node.selectionSet) {
74
- return selectionSet;
75
- }
76
- const newChildSet = mapNodeAtPath(node.selectionSet, rest, fn, pruneEmptyParent);
77
- if (newChildSet === node.selectionSet) {
78
- return selectionSet;
79
- }
80
- if (pruneEmptyParent && newChildSet.selections.length === 0) {
81
- const newSelections2 = selectionSet.selections.filter((_, i) => i !== nodeIndex);
82
- return {
83
- ...selectionSet,
84
- selections: newSelections2
85
- };
86
- }
87
- const updated = {
88
- ...node,
89
- selectionSet: newChildSet
90
- };
91
- const newSelections = [...selectionSet.selections];
92
- newSelections[nodeIndex] = updated;
93
- return {
94
- ...selectionSet,
95
- selections: newSelections
96
- };
64
+ const [segment, ...rest] = path;
65
+ const nodeIndex = selectionSet.selections.findIndex((s) => selectionMatchesSegment(s, segment));
66
+ if (nodeIndex === -1) return selectionSet;
67
+ const node = selectionSet.selections[nodeIndex];
68
+ if (rest.length === 0) {
69
+ const replacement = fn(node);
70
+ const newSelections = [...selectionSet.selections];
71
+ if (replacement === null) newSelections.splice(nodeIndex, 1);
72
+ else newSelections[nodeIndex] = replacement;
73
+ return {
74
+ ...selectionSet,
75
+ selections: newSelections
76
+ };
77
+ }
78
+ if (!node.selectionSet) return selectionSet;
79
+ const newChildSet = mapNodeAtPath(node.selectionSet, rest, fn, pruneEmptyParent);
80
+ if (newChildSet === node.selectionSet) return selectionSet;
81
+ if (pruneEmptyParent && newChildSet.selections.length === 0) {
82
+ const newSelections = selectionSet.selections.filter((_, i) => i !== nodeIndex);
83
+ return {
84
+ ...selectionSet,
85
+ selections: newSelections
86
+ };
87
+ }
88
+ const updated = {
89
+ ...node,
90
+ selectionSet: newChildSet
91
+ };
92
+ const newSelections = [...selectionSet.selections];
93
+ newSelections[nodeIndex] = updated;
94
+ return {
95
+ ...selectionSet,
96
+ selections: newSelections
97
+ };
97
98
  }
99
+ /** Creates the field or inline fragment for `segment`, with the given child set. */
98
100
  function createSelectionForSegment(segment, selectionSet) {
99
- switch (segment.kind) {
100
- case "inlineFragment":
101
- return {
102
- kind: Kind.INLINE_FRAGMENT,
103
- typeCondition: {
104
- kind: Kind.NAMED_TYPE,
105
- name: {
106
- kind: Kind.NAME,
107
- value: segment.typeName
108
- }
109
- },
110
- directives: [],
111
- selectionSet: selectionSet ?? {
112
- kind: Kind.SELECTION_SET,
113
- selections: []
114
- }
115
- };
116
- case "field":
117
- return {
118
- kind: Kind.FIELD,
119
- name: {
120
- kind: Kind.NAME,
121
- value: segment.name
122
- },
123
- arguments: [],
124
- directives: [],
125
- selectionSet
126
- };
127
- }
101
+ switch (segment.kind) {
102
+ case "inlineFragment": return {
103
+ kind: Kind.INLINE_FRAGMENT,
104
+ typeCondition: {
105
+ kind: Kind.NAMED_TYPE,
106
+ name: {
107
+ kind: Kind.NAME,
108
+ value: segment.typeName
109
+ }
110
+ },
111
+ directives: [],
112
+ selectionSet: selectionSet ?? {
113
+ kind: Kind.SELECTION_SET,
114
+ selections: []
115
+ }
116
+ };
117
+ case "field": return {
118
+ kind: Kind.FIELD,
119
+ name: {
120
+ kind: Kind.NAME,
121
+ value: segment.name
122
+ },
123
+ arguments: [],
124
+ directives: [],
125
+ selectionSet
126
+ };
127
+ }
128
128
  }
129
129
  function addField(selectionSet, path) {
130
- const [segment, ...rest] = path;
131
- if (rest.length === 0) {
132
- const alreadyPresent = selectionSet.selections.some((s) => selectionMatchesSegment(s, segment));
133
- if (alreadyPresent) {
134
- return selectionSet;
135
- }
136
- const newNode = createSelectionForSegment(segment);
137
- return {
138
- ...selectionSet,
139
- selections: [...selectionSet.selections, newNode]
140
- };
141
- }
142
- const existingIndex = selectionSet.selections.findIndex((s) => selectionMatchesSegment(s, segment));
143
- if (existingIndex === -1) {
144
- const emptySet = {
145
- kind: Kind.SELECTION_SET,
146
- selections: []
147
- };
148
- const parentNode = createSelectionForSegment(segment, addField(emptySet, rest));
149
- return {
150
- ...selectionSet,
151
- selections: [...selectionSet.selections, parentNode]
152
- };
153
- }
154
- const existing = selectionSet.selections[existingIndex];
155
- const childSet = existing.selectionSet ?? {
156
- kind: Kind.SELECTION_SET,
157
- selections: []
158
- };
159
- const updated = {
160
- ...existing,
161
- selectionSet: addField(childSet, rest)
162
- };
163
- const newSelections = [...selectionSet.selections];
164
- newSelections[existingIndex] = updated;
165
- return {
166
- ...selectionSet,
167
- selections: newSelections
168
- };
130
+ const [segment, ...rest] = path;
131
+ if (rest.length === 0) {
132
+ if (selectionSet.selections.some((s) => selectionMatchesSegment(s, segment))) return selectionSet;
133
+ const newNode = createSelectionForSegment(segment);
134
+ return {
135
+ ...selectionSet,
136
+ selections: [...selectionSet.selections, newNode]
137
+ };
138
+ }
139
+ const existingIndex = selectionSet.selections.findIndex((s) => selectionMatchesSegment(s, segment));
140
+ if (existingIndex === -1) {
141
+ const parentNode = createSelectionForSegment(segment, addField({
142
+ kind: Kind.SELECTION_SET,
143
+ selections: []
144
+ }, rest));
145
+ return {
146
+ ...selectionSet,
147
+ selections: [...selectionSet.selections, parentNode]
148
+ };
149
+ }
150
+ const existing = selectionSet.selections[existingIndex];
151
+ const childSet = existing.selectionSet ?? {
152
+ kind: Kind.SELECTION_SET,
153
+ selections: []
154
+ };
155
+ const updated = {
156
+ ...existing,
157
+ selectionSet: addField(childSet, rest)
158
+ };
159
+ const newSelections = [...selectionSet.selections];
160
+ newSelections[existingIndex] = updated;
161
+ return {
162
+ ...selectionSet,
163
+ selections: newSelections
164
+ };
169
165
  }
170
166
  function removeField(selectionSet, path) {
171
- return mapNodeAtPath(selectionSet, path, () => null, true);
167
+ return mapNodeAtPath(selectionSet, path, () => null, true);
172
168
  }
173
169
  function replaceFieldSelectionSet(selectionSet, path, newSet) {
174
- return mapNodeAtPath(selectionSet, path, (node) => ({
175
- ...node,
176
- selectionSet: newSet
177
- }), false);
170
+ return mapNodeAtPath(selectionSet, path, (node) => ({
171
+ ...node,
172
+ selectionSet: newSet
173
+ }), false);
178
174
  }
179
175
  function setArgInSelectionSet(selectionSet, path, argName, value) {
180
- return mapNodeAtPath(
181
- selectionSet,
182
- path,
183
- (node) => {
184
- const field = node;
185
- const existingArgs = field.arguments ?? [];
186
- let newArgs;
187
- if (value === void 0) {
188
- newArgs = existingArgs.filter((a) => a.name.value !== argName);
189
- } else {
190
- const existingIndex = existingArgs.findIndex((a) => a.name.value === argName);
191
- const newArg = {
192
- kind: Kind.ARGUMENT,
193
- name: {
194
- kind: Kind.NAME,
195
- value: argName
196
- },
197
- value
198
- };
199
- if (existingIndex === -1) {
200
- newArgs = [...existingArgs, newArg];
201
- } else {
202
- newArgs = [...existingArgs];
203
- newArgs[existingIndex] = newArg;
204
- }
205
- }
206
- return {
207
- ...field,
208
- arguments: newArgs
209
- };
210
- },
211
- false
212
- // do not prune empty parents when setting args
213
- );
176
+ return mapNodeAtPath(selectionSet, path, (node) => {
177
+ const field = node;
178
+ const existingArgs = field.arguments ?? [];
179
+ let newArgs;
180
+ if (value === void 0) newArgs = existingArgs.filter((a) => a.name.value !== argName);
181
+ else {
182
+ const existingIndex = existingArgs.findIndex((a) => a.name.value === argName);
183
+ const newArg = {
184
+ kind: Kind.ARGUMENT,
185
+ name: {
186
+ kind: Kind.NAME,
187
+ value: argName
188
+ },
189
+ value
190
+ };
191
+ if (existingIndex === -1) newArgs = [...existingArgs, newArg];
192
+ else {
193
+ newArgs = [...existingArgs];
194
+ newArgs[existingIndex] = newArg;
195
+ }
196
+ }
197
+ return {
198
+ ...field,
199
+ arguments: newArgs
200
+ };
201
+ }, false);
214
202
  }
215
203
  function findSelectionSet(selectionSet, path) {
216
- const node = findNodeAtPath(selectionSet, path);
217
- return node == null ? void 0 : node.selectionSet;
204
+ return findNodeAtPath(selectionSet, path)?.selectionSet;
218
205
  }
206
+ /**
207
+ * Returns the index in `doc.definitions` of the operation to operate on:
208
+ * the operation whose name matches `operationName` when given and present,
209
+ * otherwise the first operation definition. Returns -1 when the document has
210
+ * no operation definitions.
211
+ */
219
212
  function findOperationIndex(doc, operationName) {
220
- if (operationName) {
221
- const named = doc.definitions.findIndex((d) => {
222
- var _a;
223
- return d.kind === Kind.OPERATION_DEFINITION && ((_a = d.name) == null ? void 0 : _a.value) === operationName;
224
- });
225
- if (named !== -1) {
226
- return named;
227
- }
228
- }
229
- return doc.definitions.findIndex((d) => d.kind === Kind.OPERATION_DEFINITION);
213
+ if (operationName) {
214
+ const named = doc.definitions.findIndex((d) => d.kind === Kind.OPERATION_DEFINITION && d.name?.value === operationName);
215
+ if (named !== -1) return named;
216
+ }
217
+ return doc.definitions.findIndex((d) => d.kind === Kind.OPERATION_DEFINITION);
230
218
  }
219
+ /**
220
+ * Resolves the target operation node (see {@link findOperationIndex}), or
221
+ * `undefined` when the document has no matching operation.
222
+ */
231
223
  function findOperation(doc, operationName) {
232
- const index = findOperationIndex(doc, operationName);
233
- if (index === -1) {
234
- return void 0;
235
- }
236
- const operation = doc.definitions[index];
237
- return (operation == null ? void 0 : operation.kind) === Kind.OPERATION_DEFINITION ? operation : void 0;
224
+ const index = findOperationIndex(doc, operationName);
225
+ if (index === -1) return;
226
+ const operation = doc.definitions[index];
227
+ return operation?.kind === Kind.OPERATION_DEFINITION ? operation : void 0;
238
228
  }
229
+ /**
230
+ * Finds the target operation, calls `fn` with it, and returns a new
231
+ * `DocumentNode` with the result spliced back into `definitions`. When `fn`
232
+ * returns `null` the operation is removed entirely (used when an operation
233
+ * becomes empty and unprintable). Returns `doc` unchanged when no matching
234
+ * operation definition exists.
235
+ */
239
236
  function mapOperation(doc, operationName, fn) {
240
- const index = findOperationIndex(doc, operationName);
241
- if (index === -1) {
242
- return doc;
243
- }
244
- const def = doc.definitions[index];
245
- if ((def == null ? void 0 : def.kind) !== Kind.OPERATION_DEFINITION) {
246
- return doc;
247
- }
248
- const result = fn(def);
249
- if (result === def) {
250
- return doc;
251
- }
252
- const newDefinitions = [...doc.definitions];
253
- if (result === null) {
254
- newDefinitions.splice(index, 1);
255
- } else {
256
- newDefinitions[index] = result;
257
- }
258
- return {
259
- ...doc,
260
- definitions: newDefinitions
261
- };
237
+ const index = findOperationIndex(doc, operationName);
238
+ if (index === -1) return doc;
239
+ const def = doc.definitions[index];
240
+ if (def?.kind !== Kind.OPERATION_DEFINITION) return doc;
241
+ const result = fn(def);
242
+ if (result === def) return doc;
243
+ const newDefinitions = [...doc.definitions];
244
+ if (result === null) newDefinitions.splice(index, 1);
245
+ else newDefinitions[index] = result;
246
+ return {
247
+ ...doc,
248
+ definitions: newDefinitions
249
+ };
262
250
  }
251
+ /**
252
+ * Returns the index in `doc.definitions` of the definition addressed by
253
+ * `target` — the matching operation (see {@link findOperationIndex}) or the
254
+ * named fragment. Returns -1 when no such definition exists.
255
+ */
263
256
  function findDefinitionIndex(doc, target) {
264
- if (target.kind === "operation") {
265
- return findOperationIndex(doc, target.name);
266
- }
267
- return doc.definitions.findIndex((d) => d.kind === Kind.FRAGMENT_DEFINITION && d.name.value === target.name);
257
+ if (target.kind === "operation") return findOperationIndex(doc, target.name);
258
+ return doc.definitions.findIndex((d) => d.kind === Kind.FRAGMENT_DEFINITION && d.name.value === target.name);
268
259
  }
260
+ /**
261
+ * Resolves the definition node addressed by `target`, or `undefined` when the
262
+ * document has no matching definition.
263
+ */
269
264
  function findDefinition(doc, target) {
270
- const index = findDefinitionIndex(doc, target);
271
- if (index === -1) {
272
- return void 0;
273
- }
274
- const def = doc.definitions[index];
275
- if ((def == null ? void 0 : def.kind) === Kind.OPERATION_DEFINITION || (def == null ? void 0 : def.kind) === Kind.FRAGMENT_DEFINITION) {
276
- return def;
277
- }
278
- return void 0;
265
+ const index = findDefinitionIndex(doc, target);
266
+ if (index === -1) return;
267
+ const def = doc.definitions[index];
268
+ if (def?.kind === Kind.OPERATION_DEFINITION || def?.kind === Kind.FRAGMENT_DEFINITION) return def;
279
269
  }
270
+ /**
271
+ * Finds the definition addressed by `target`, calls `fn` with it, and returns a
272
+ * new `DocumentNode` with the result spliced back into `definitions`. When `fn`
273
+ * returns `null` the definition is removed entirely. Returns `doc` unchanged
274
+ * when no matching definition exists or `fn` returns the same reference.
275
+ */
280
276
  function mapDefinition(doc, target, fn) {
281
- const index = findDefinitionIndex(doc, target);
282
- if (index === -1) {
283
- return doc;
284
- }
285
- const def = doc.definitions[index];
286
- if ((def == null ? void 0 : def.kind) !== Kind.OPERATION_DEFINITION && (def == null ? void 0 : def.kind) !== Kind.FRAGMENT_DEFINITION) {
287
- return doc;
288
- }
289
- const result = fn(def);
290
- if (result === def) {
291
- return doc;
292
- }
293
- const newDefinitions = [...doc.definitions];
294
- if (result === null) {
295
- newDefinitions.splice(index, 1);
296
- } else {
297
- newDefinitions[index] = result;
298
- }
299
- return {
300
- ...doc,
301
- definitions: newDefinitions
302
- };
277
+ const index = findDefinitionIndex(doc, target);
278
+ if (index === -1) return doc;
279
+ const def = doc.definitions[index];
280
+ if (def?.kind !== Kind.OPERATION_DEFINITION && def?.kind !== Kind.FRAGMENT_DEFINITION) return doc;
281
+ const result = fn(def);
282
+ if (result === def) return doc;
283
+ const newDefinitions = [...doc.definitions];
284
+ if (result === null) newDefinitions.splice(index, 1);
285
+ else newDefinitions[index] = result;
286
+ return {
287
+ ...doc,
288
+ definitions: newDefinitions
289
+ };
303
290
  }
291
+ /**
292
+ * A source offset just inside the selection set of the definition addressed by
293
+ * `target`, or `undefined` when it can't be located. Used to move the editor
294
+ * cursor into a definition so the builder — which follows the cursor — switches
295
+ * to editing it. Requires `doc` to carry location info (parse without
296
+ * `noLocation`).
297
+ */
304
298
  function definitionSelectionOffset(doc, target) {
305
- var _a;
306
- const loc = (_a = findDefinition(doc, target)) == null ? void 0 : _a.selectionSet.loc;
307
- return loc ? loc.start + 1 : void 0;
299
+ const loc = findDefinition(doc, target)?.selectionSet.loc;
300
+ return loc ? loc.start + 1 : void 0;
308
301
  }
309
- export {
310
- addField,
311
- createSelectionForSegment,
312
- definitionSelectionOffset,
313
- fieldSegment,
314
- findDefinition,
315
- findDefinitionIndex,
316
- findNodeAtPath,
317
- findOperation,
318
- findOperationIndex,
319
- findSelectionSet,
320
- inlineFragmentSegment,
321
- mapDefinition,
322
- mapNodeAtPath,
323
- mapOperation,
324
- removeField,
325
- replaceFieldSelectionSet,
326
- segmentsEqual,
327
- selectionMatchesSegment,
328
- setArgInSelectionSet
329
- };
330
- //# sourceMappingURL=ast-path.js.map
302
+ //#endregion
303
+ export { addField, createSelectionForSegment, definitionSelectionOffset, fieldSegment, findDefinition, findDefinitionIndex, findNodeAtPath, findOperation, findOperationIndex, findSelectionSet, inlineFragmentSegment, mapDefinition, mapNodeAtPath, mapOperation, removeField, replaceFieldSelectionSet, segmentsEqual, selectionMatchesSegment, setArgInSelectionSet };
304
+
305
+ //# sourceMappingURL=ast-path.js.map