@graphiql/plugin-query-builder 1.0.0 → 1.0.1
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.
- package/dist/components/arg-input/arg-input-by-type.js +1 -2
- package/dist/components/arg-input/arg-input-by-type.js.map +1 -1
- package/dist/components/arg-input/enum-arg-control.js +1 -2
- package/dist/components/arg-input/enum-arg-control.js.map +1 -1
- package/dist/components/arg-input/index.js +1 -2
- package/dist/components/arg-input/index.js.map +1 -1
- package/dist/components/arg-input/scalar-arg-control.js +1 -2
- package/dist/components/arg-input/scalar-arg-control.js.map +1 -1
- package/dist/components/field-row.js +1 -2
- package/dist/components/field-row.js.map +1 -1
- package/dist/components/field-tree-context.d.ts +1 -1
- package/dist/components/field-tree-context.js +1 -2
- package/dist/components/field-tree-context.js.map +1 -1
- package/dist/components/field-tree-node.js +228 -92
- package/dist/components/field-tree-node.js.map +1 -1
- package/dist/components/field-tree.js +2 -3
- package/dist/components/field-tree.js.map +1 -1
- package/dist/components/fragment-editor.js +1 -2
- package/dist/components/fragment-editor.js.map +1 -1
- package/dist/components/fragment-section.js +1 -2
- package/dist/components/fragment-section.js.map +1 -1
- package/dist/components/query-builder.js +81 -91
- package/dist/components/query-builder.js.map +1 -1
- package/dist/components/type-condition-selector.js +193 -203
- package/dist/components/type-condition-selector.js.map +1 -1
- package/dist/components/use-cursor-path.js +1 -2
- package/dist/components/use-cursor-path.js.map +1 -1
- package/dist/components/use-cursor-reveal.d.ts +3 -1
- package/dist/components/use-cursor-reveal.js +49 -46
- package/dist/components/use-cursor-reveal.js.map +1 -1
- package/dist/components/use-working-document.js +295 -281
- package/dist/components/use-working-document.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/lib/arg-value.js +1 -2
- package/dist/lib/arguments.js +1 -2
- package/dist/lib/ast-path.js +1 -2
- package/dist/lib/field-list-view.js +1 -2
- package/dist/lib/field-selection.js +1 -2
- package/dist/lib/fragments.js +1 -2
- package/dist/lib/inline-fragments.js +1 -2
- package/dist/lib/schema-walk.js +1 -2
- package/dist/lib/variables.js +1 -2
- package/package.json +10 -8
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { extractRawArgValue, readVariables, resolveSchemaArg, resolveSchemaArgFromRoot } from "../lib/schema-walk.js";
|
|
1
|
+
import { addInlineFragment, removeInlineFragment } from "../lib/inline-fragments.js";
|
|
3
2
|
import { argValueToValueNode } from "../lib/arg-value.js";
|
|
4
|
-
import { toggleFieldSelection } from "../lib/field-selection.js";
|
|
5
|
-
import { setFieldArgument } from "../lib/arguments.js";
|
|
6
|
-
import { demoteVariable, promoteArgToVariable, suggestVarName } from "../lib/variables.js";
|
|
7
3
|
import { createFragmentFromSelection, inlineFragment, listFragments, removeFragmentSpread, renameFragment } from "../lib/fragments.js";
|
|
8
|
-
import {
|
|
4
|
+
import { demoteVariable, promoteArgToVariable, suggestVarName } from "../lib/variables.js";
|
|
5
|
+
import { definitionSelectionOffset, findDefinition, findOperation } from "../lib/ast-path.js";
|
|
6
|
+
import { setFieldArgument } from "../lib/arguments.js";
|
|
7
|
+
import { toggleFieldSelection } from "../lib/field-selection.js";
|
|
8
|
+
import { extractRawArgValue, readVariables, resolveSchemaArg, resolveSchemaArgFromRoot } from "../lib/schema-walk.js";
|
|
9
9
|
import { useCursorContext } from "./use-cursor-path.js";
|
|
10
10
|
import { useGraphiQL, useGraphiQLActions } from "@graphiql/react";
|
|
11
11
|
import { c } from "react-compiler-runtime";
|
|
12
12
|
import { Kind, getNamedType, parse, parseValue, print, valueFromASTUntyped } from "graphql";
|
|
13
|
-
import { useEffect,
|
|
14
|
-
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
// src/components/use-working-document.ts
|
|
15
15
|
/**
|
|
16
16
|
* Parse query text into a DocumentNode, or null when it's empty or unparseable
|
|
17
17
|
* (callers keep the last valid document instead).
|
|
@@ -34,7 +34,7 @@ function emptyDoc() {
|
|
|
34
34
|
* external-edit sync, and all document-mutation handlers.
|
|
35
35
|
*/
|
|
36
36
|
function useWorkingDocument() {
|
|
37
|
-
const $ = c(
|
|
37
|
+
const $ = c(112);
|
|
38
38
|
const schema = useGraphiQL(_temp);
|
|
39
39
|
const queryEditor = useGraphiQL(_temp2);
|
|
40
40
|
const variableEditor = useGraphiQL(_temp3);
|
|
@@ -46,12 +46,21 @@ function useWorkingDocument() {
|
|
|
46
46
|
const variablesText = tabs[activeTabIndex]?.variables;
|
|
47
47
|
let t0;
|
|
48
48
|
if ($[0] !== queryText) {
|
|
49
|
-
t0 = () =>
|
|
49
|
+
t0 = () => ({
|
|
50
|
+
doc: tryParse(queryText) ?? emptyDoc(),
|
|
51
|
+
observedText: queryText,
|
|
52
|
+
syncedText: queryText ?? null
|
|
53
|
+
});
|
|
50
54
|
$[0] = queryText;
|
|
51
55
|
$[1] = t0;
|
|
52
56
|
} else t0 = $[1];
|
|
53
|
-
const [
|
|
54
|
-
const
|
|
57
|
+
const [documentState, setDocumentState] = useState(t0);
|
|
58
|
+
const workingDoc = documentState.doc;
|
|
59
|
+
if (queryText !== documentState.observedText) setDocumentState({
|
|
60
|
+
doc: queryText === documentState.syncedText ? workingDoc : tryParse(queryText) ?? (queryText?.trim() ? workingDoc : emptyDoc()),
|
|
61
|
+
observedText: queryText,
|
|
62
|
+
syncedText: queryText ?? null
|
|
63
|
+
});
|
|
55
64
|
let t1;
|
|
56
65
|
if ($[2] !== queryEditor || $[3] !== updateActiveTabValues) {
|
|
57
66
|
t1 = (printed) => {
|
|
@@ -59,11 +68,10 @@ function useWorkingDocument() {
|
|
|
59
68
|
const position = queryEditor.getPosition();
|
|
60
69
|
queryEditor.setValue(printed);
|
|
61
70
|
if (position) queryEditor.setPosition(position);
|
|
62
|
-
|
|
63
|
-
return;
|
|
71
|
+
return queryEditor.getValue();
|
|
64
72
|
}
|
|
65
|
-
lastSyncedRef.current = printed;
|
|
66
73
|
updateActiveTabValues({ query: printed });
|
|
74
|
+
return printed;
|
|
67
75
|
};
|
|
68
76
|
$[2] = queryEditor;
|
|
69
77
|
$[3] = updateActiveTabValues;
|
|
@@ -71,80 +79,65 @@ function useWorkingDocument() {
|
|
|
71
79
|
} else t1 = $[4];
|
|
72
80
|
const writeToEditor = t1;
|
|
73
81
|
let t2;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
$[5] = queryText;
|
|
85
|
-
$[6] = t2;
|
|
86
|
-
$[7] = t3;
|
|
87
|
-
} else {
|
|
88
|
-
t2 = $[6];
|
|
89
|
-
t3 = $[7];
|
|
90
|
-
}
|
|
91
|
-
useEffect(t2, t3);
|
|
82
|
+
if ($[5] !== operationName || $[6] !== workingDoc) {
|
|
83
|
+
t2 = findOperation(workingDoc, operationName)?.operation;
|
|
84
|
+
$[5] = operationName;
|
|
85
|
+
$[6] = workingDoc;
|
|
86
|
+
$[7] = t2;
|
|
87
|
+
} else t2 = $[7];
|
|
88
|
+
const activeOpKind = t2;
|
|
89
|
+
const cursor = useCursorContext();
|
|
90
|
+
const cursorFragment = cursor.target?.kind === "fragment" ? cursor.target.name : cursor.target?.kind === "operation" ? null : void 0;
|
|
91
|
+
const t3 = cursorFragment ?? null;
|
|
92
92
|
let t4;
|
|
93
|
-
if ($[8] !==
|
|
94
|
-
t4 =
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
if ($[8] !== cursorFragment || $[9] !== t3) {
|
|
94
|
+
t4 = {
|
|
95
|
+
name: t3,
|
|
96
|
+
cursorFragment
|
|
97
|
+
};
|
|
98
|
+
$[8] = cursorFragment;
|
|
99
|
+
$[9] = t3;
|
|
97
100
|
$[10] = t4;
|
|
98
101
|
} else t4 = $[10];
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const [activeFragment, setActiveFragment] = useState(null);
|
|
102
|
-
const cursorFragment = cursor.target?.kind === "fragment" ? cursor.target.name : cursor.target?.kind === "operation" ? null : void 0;
|
|
102
|
+
const [fragmentState, setFragmentState] = useState(t4);
|
|
103
|
+
const activeFragment = cursorFragment !== fragmentState.cursorFragment && cursorFragment !== void 0 ? cursorFragment : fragmentState.name;
|
|
103
104
|
let t5;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
t5 = () => {
|
|
107
|
-
if (cursorFragment !== void 0) setActiveFragment(cursorFragment);
|
|
108
|
-
};
|
|
109
|
-
t6 = [cursorFragment];
|
|
110
|
-
$[11] = cursorFragment;
|
|
111
|
-
$[12] = t5;
|
|
112
|
-
$[13] = t6;
|
|
113
|
-
} else {
|
|
114
|
-
t5 = $[12];
|
|
115
|
-
t6 = $[13];
|
|
116
|
-
}
|
|
117
|
-
useEffect(t5, t6);
|
|
118
|
-
let t7;
|
|
119
|
-
if ($[14] !== activeFragment || $[15] !== workingDoc) {
|
|
120
|
-
t7 = activeFragment != null && findDefinition(workingDoc, {
|
|
105
|
+
if ($[11] !== activeFragment || $[12] !== workingDoc) {
|
|
106
|
+
t5 = activeFragment != null && findDefinition(workingDoc, {
|
|
121
107
|
kind: "fragment",
|
|
122
108
|
name: activeFragment
|
|
123
109
|
}) ? activeFragment : null;
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
} else
|
|
128
|
-
const visibleFragment =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
110
|
+
$[11] = activeFragment;
|
|
111
|
+
$[12] = workingDoc;
|
|
112
|
+
$[13] = t5;
|
|
113
|
+
} else t5 = $[13];
|
|
114
|
+
const visibleFragment = t5;
|
|
115
|
+
if (fragmentState.cursorFragment !== cursorFragment || fragmentState.name !== visibleFragment || fragmentState.resetCursor && fragmentState.resetCursor.editor !== queryEditor) setFragmentState({
|
|
116
|
+
name: visibleFragment,
|
|
117
|
+
cursorFragment,
|
|
118
|
+
resetCursor: activeFragment != null && visibleFragment == null ? {
|
|
119
|
+
operationName,
|
|
120
|
+
editor: queryEditor
|
|
121
|
+
} : void 0
|
|
122
|
+
});
|
|
123
|
+
let t6;
|
|
124
|
+
if ($[14] !== operationName || $[15] !== visibleFragment) {
|
|
125
|
+
t6 = visibleFragment != null ? {
|
|
132
126
|
kind: "fragment",
|
|
133
127
|
name: visibleFragment
|
|
134
128
|
} : {
|
|
135
129
|
kind: "operation",
|
|
136
130
|
name: operationName
|
|
137
131
|
};
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
} else
|
|
142
|
-
const target =
|
|
132
|
+
$[14] = operationName;
|
|
133
|
+
$[15] = visibleFragment;
|
|
134
|
+
$[16] = t6;
|
|
135
|
+
} else t6 = $[16];
|
|
136
|
+
const target = t6;
|
|
143
137
|
const cursorPath = cursor.target != null && (visibleFragment != null ? cursor.target.kind === "fragment" && cursor.target.name === visibleFragment : cursor.target.kind === "operation") ? cursor.path : void 0;
|
|
144
|
-
let
|
|
145
|
-
if ($[
|
|
146
|
-
|
|
147
|
-
setActiveFragment(next.kind === "fragment" ? next.name : null);
|
|
138
|
+
let t7;
|
|
139
|
+
if ($[17] !== queryEditor) {
|
|
140
|
+
t7 = (next) => {
|
|
148
141
|
if (!queryEditor) return;
|
|
149
142
|
const model = queryEditor.getModel();
|
|
150
143
|
if (!model) return;
|
|
@@ -156,88 +149,110 @@ function useWorkingDocument() {
|
|
|
156
149
|
}
|
|
157
150
|
if (offset != null) queryEditor.setPosition(model.getPositionAt(offset));
|
|
158
151
|
};
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
} else
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
$[17] = queryEditor;
|
|
153
|
+
$[18] = t7;
|
|
154
|
+
} else t7 = $[18];
|
|
155
|
+
const moveEditorCursorToTarget = t7;
|
|
156
|
+
const resetCursor = fragmentState.resetCursor;
|
|
157
|
+
let t8;
|
|
158
|
+
let t9;
|
|
159
|
+
if ($[19] !== moveEditorCursorToTarget || $[20] !== queryEditor || $[21] !== resetCursor) {
|
|
160
|
+
t8 = () => {
|
|
161
|
+
if (resetCursor && resetCursor.editor === queryEditor) moveEditorCursorToTarget({
|
|
168
162
|
kind: "operation",
|
|
169
|
-
name: operationName
|
|
163
|
+
name: resetCursor.operationName
|
|
170
164
|
});
|
|
171
165
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
moveCursorToTarget
|
|
166
|
+
t9 = [
|
|
167
|
+
resetCursor,
|
|
168
|
+
queryEditor,
|
|
169
|
+
moveEditorCursorToTarget
|
|
177
170
|
];
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[27] = t11;
|
|
171
|
+
$[19] = moveEditorCursorToTarget;
|
|
172
|
+
$[20] = queryEditor;
|
|
173
|
+
$[21] = resetCursor;
|
|
174
|
+
$[22] = t8;
|
|
175
|
+
$[23] = t9;
|
|
184
176
|
} else {
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
t8 = $[22];
|
|
178
|
+
t9 = $[23];
|
|
187
179
|
}
|
|
188
|
-
useEffect(
|
|
189
|
-
let
|
|
190
|
-
if ($[
|
|
191
|
-
|
|
180
|
+
useEffect(t8, t9);
|
|
181
|
+
let t10;
|
|
182
|
+
if ($[24] !== moveEditorCursorToTarget) {
|
|
183
|
+
t10 = function moveCursorToTarget(next_0) {
|
|
184
|
+
setFragmentState((state_5) => ({
|
|
185
|
+
...state_5,
|
|
186
|
+
name: next_0.kind === "fragment" ? next_0.name : null,
|
|
187
|
+
resetCursor: void 0
|
|
188
|
+
}));
|
|
189
|
+
moveEditorCursorToTarget(next_0);
|
|
190
|
+
};
|
|
191
|
+
$[24] = moveEditorCursorToTarget;
|
|
192
|
+
$[25] = t10;
|
|
193
|
+
} else t10 = $[25];
|
|
194
|
+
const moveCursorToTarget = t10;
|
|
195
|
+
let t11;
|
|
196
|
+
if ($[26] !== moveCursorToTarget) {
|
|
197
|
+
t11 = function handleFocusFragment(fragmentName) {
|
|
192
198
|
moveCursorToTarget({
|
|
193
199
|
kind: "fragment",
|
|
194
200
|
name: fragmentName
|
|
195
201
|
});
|
|
196
202
|
};
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
} else
|
|
200
|
-
const handleFocusFragment =
|
|
201
|
-
let
|
|
202
|
-
if ($[
|
|
203
|
-
|
|
203
|
+
$[26] = moveCursorToTarget;
|
|
204
|
+
$[27] = t11;
|
|
205
|
+
} else t11 = $[27];
|
|
206
|
+
const handleFocusFragment = t11;
|
|
207
|
+
let t12;
|
|
208
|
+
if ($[28] !== moveCursorToTarget || $[29] !== operationName) {
|
|
209
|
+
t12 = function handleBackToQuery() {
|
|
204
210
|
moveCursorToTarget({
|
|
205
211
|
kind: "operation",
|
|
206
212
|
name: operationName
|
|
207
213
|
});
|
|
208
214
|
};
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
215
|
+
$[28] = moveCursorToTarget;
|
|
216
|
+
$[29] = operationName;
|
|
217
|
+
$[30] = t12;
|
|
218
|
+
} else t12 = $[30];
|
|
219
|
+
const handleBackToQuery = t12;
|
|
220
|
+
let t13;
|
|
221
|
+
if ($[31] !== writeToEditor) {
|
|
222
|
+
t13 = function applyDoc(next_1) {
|
|
223
|
+
const printed_0 = print(next_1);
|
|
224
|
+
setDocumentState((state_6) => ({
|
|
225
|
+
...state_6,
|
|
226
|
+
doc: next_1,
|
|
227
|
+
syncedText: printed_0
|
|
228
|
+
}));
|
|
229
|
+
const syncedText = writeToEditor(printed_0);
|
|
230
|
+
if (syncedText !== printed_0) setDocumentState((state_7) => ({
|
|
231
|
+
...state_7,
|
|
232
|
+
syncedText
|
|
233
|
+
}));
|
|
234
|
+
};
|
|
235
|
+
$[31] = writeToEditor;
|
|
211
236
|
$[32] = t13;
|
|
212
237
|
} else t13 = $[32];
|
|
213
|
-
const
|
|
238
|
+
const applyDoc = t13;
|
|
214
239
|
let t14;
|
|
215
|
-
if ($[33] !==
|
|
216
|
-
t14 = function
|
|
217
|
-
|
|
218
|
-
writeToEditor(print(next_0));
|
|
219
|
-
};
|
|
220
|
-
$[33] = writeToEditor;
|
|
221
|
-
$[34] = t14;
|
|
222
|
-
} else t14 = $[34];
|
|
223
|
-
const applyDoc = t14;
|
|
224
|
-
let t15;
|
|
225
|
-
if ($[35] !== updateActiveTabValues || $[36] !== variableEditor) {
|
|
226
|
-
t15 = function applyVariables(next_1) {
|
|
227
|
-
const serialized = Object.keys(next_1).length ? JSON.stringify(next_1, null, 2) : "";
|
|
240
|
+
if ($[33] !== updateActiveTabValues || $[34] !== variableEditor) {
|
|
241
|
+
t14 = function applyVariables(next_2) {
|
|
242
|
+
const serialized = Object.keys(next_2).length ? JSON.stringify(next_2, null, 2) : "";
|
|
228
243
|
if (variableEditor) variableEditor.setValue(serialized);
|
|
229
244
|
else updateActiveTabValues({ variables: serialized });
|
|
230
245
|
};
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
} else
|
|
235
|
-
const applyVariables =
|
|
236
|
-
let
|
|
237
|
-
if ($[
|
|
238
|
-
|
|
246
|
+
$[33] = updateActiveTabValues;
|
|
247
|
+
$[34] = variableEditor;
|
|
248
|
+
$[35] = t14;
|
|
249
|
+
} else t14 = $[35];
|
|
250
|
+
const applyVariables = t14;
|
|
251
|
+
let t15;
|
|
252
|
+
if ($[36] !== applyVariables || $[37] !== variablesText) {
|
|
253
|
+
t15 = function reconcileVariablesJson(next_3) {
|
|
239
254
|
const definedVars = /* @__PURE__ */ new Set();
|
|
240
|
-
for (const def of
|
|
255
|
+
for (const def of next_3.definitions) if (def.kind === Kind.OPERATION_DEFINITION) for (const vd of def.variableDefinitions ?? []) definedVars.add(vd.variable.name.value);
|
|
241
256
|
const vars = readVariables(variablesText);
|
|
242
257
|
if (Object.keys(vars).some((name_0) => !definedVars.has(name_0))) {
|
|
243
258
|
const reconciled = {};
|
|
@@ -245,28 +260,28 @@ function useWorkingDocument() {
|
|
|
245
260
|
applyVariables(reconciled);
|
|
246
261
|
}
|
|
247
262
|
};
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
} else
|
|
252
|
-
const reconcileVariablesJson =
|
|
253
|
-
let
|
|
254
|
-
if ($[
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
applyDoc(
|
|
258
|
-
reconcileVariablesJson(
|
|
263
|
+
$[36] = applyVariables;
|
|
264
|
+
$[37] = variablesText;
|
|
265
|
+
$[38] = t15;
|
|
266
|
+
} else t15 = $[38];
|
|
267
|
+
const reconcileVariablesJson = t15;
|
|
268
|
+
let t16;
|
|
269
|
+
if ($[39] !== applyDoc || $[40] !== reconcileVariablesJson || $[41] !== target || $[42] !== workingDoc) {
|
|
270
|
+
t16 = function handleToggle(path) {
|
|
271
|
+
const next_4 = toggleFieldSelection(workingDoc, path, target);
|
|
272
|
+
applyDoc(next_4);
|
|
273
|
+
reconcileVariablesJson(next_4);
|
|
259
274
|
};
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
} else
|
|
266
|
-
const handleToggle =
|
|
267
|
-
let
|
|
268
|
-
if ($[
|
|
269
|
-
|
|
275
|
+
$[39] = applyDoc;
|
|
276
|
+
$[40] = reconcileVariablesJson;
|
|
277
|
+
$[41] = target;
|
|
278
|
+
$[42] = workingDoc;
|
|
279
|
+
$[43] = t16;
|
|
280
|
+
} else t16 = $[43];
|
|
281
|
+
const handleToggle = t16;
|
|
282
|
+
let t17;
|
|
283
|
+
if ($[44] !== activeOpKind || $[45] !== schema || $[46] !== target || $[47] !== workingDoc) {
|
|
284
|
+
t17 = function schemaArgFor(path_0, argName) {
|
|
270
285
|
if (!schema) return;
|
|
271
286
|
if (target.kind === "operation") return resolveSchemaArg(schema, activeOpKind, path_0, argName);
|
|
272
287
|
const def_0 = findDefinition(workingDoc, target);
|
|
@@ -274,31 +289,31 @@ function useWorkingDocument() {
|
|
|
274
289
|
const rootType = rootTypeName ? schema.getType(rootTypeName) ?? void 0 : void 0;
|
|
275
290
|
return resolveSchemaArgFromRoot(schema, rootType, path_0, argName);
|
|
276
291
|
};
|
|
277
|
-
$[
|
|
278
|
-
$[
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
282
|
-
} else
|
|
283
|
-
const schemaArgFor =
|
|
284
|
-
let
|
|
285
|
-
if ($[
|
|
286
|
-
|
|
292
|
+
$[44] = activeOpKind;
|
|
293
|
+
$[45] = schema;
|
|
294
|
+
$[46] = target;
|
|
295
|
+
$[47] = workingDoc;
|
|
296
|
+
$[48] = t17;
|
|
297
|
+
} else t17 = $[48];
|
|
298
|
+
const schemaArgFor = t17;
|
|
299
|
+
let t18;
|
|
300
|
+
if ($[49] !== applyDoc || $[50] !== schemaArgFor || $[51] !== target || $[52] !== workingDoc) {
|
|
301
|
+
t18 = function handleSetArg(path_1, argName_0, value_0) {
|
|
287
302
|
const schemaArg = schemaArgFor(path_1, argName_0);
|
|
288
303
|
if (!schemaArg) return;
|
|
289
304
|
const valueNode = argValueToValueNode(schemaArg.type, value_0);
|
|
290
305
|
applyDoc(setFieldArgument(workingDoc, path_1, argName_0, valueNode, target));
|
|
291
306
|
};
|
|
292
|
-
$[
|
|
293
|
-
$[
|
|
294
|
-
$[
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
} else
|
|
298
|
-
const handleSetArg =
|
|
299
|
-
let
|
|
300
|
-
if ($[
|
|
301
|
-
|
|
307
|
+
$[49] = applyDoc;
|
|
308
|
+
$[50] = schemaArgFor;
|
|
309
|
+
$[51] = target;
|
|
310
|
+
$[52] = workingDoc;
|
|
311
|
+
$[53] = t18;
|
|
312
|
+
} else t18 = $[53];
|
|
313
|
+
const handleSetArg = t18;
|
|
314
|
+
let t19;
|
|
315
|
+
if ($[54] !== applyDoc || $[55] !== applyVariables || $[56] !== operationName || $[57] !== schemaArgFor || $[58] !== variablesText || $[59] !== workingDoc) {
|
|
316
|
+
t19 = function handlePromoteArg(path_2, argName_1, suggestedName) {
|
|
302
317
|
const schemaArg_0 = schemaArgFor(path_2, argName_1);
|
|
303
318
|
if (!schemaArg_0) return;
|
|
304
319
|
const namedType = getNamedType(schemaArg_0.type);
|
|
@@ -314,18 +329,18 @@ function useWorkingDocument() {
|
|
|
314
329
|
});
|
|
315
330
|
} catch {}
|
|
316
331
|
};
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
} else
|
|
325
|
-
const handlePromoteArg =
|
|
326
|
-
let
|
|
327
|
-
if ($[
|
|
328
|
-
|
|
332
|
+
$[54] = applyDoc;
|
|
333
|
+
$[55] = applyVariables;
|
|
334
|
+
$[56] = operationName;
|
|
335
|
+
$[57] = schemaArgFor;
|
|
336
|
+
$[58] = variablesText;
|
|
337
|
+
$[59] = workingDoc;
|
|
338
|
+
$[60] = t19;
|
|
339
|
+
} else t19 = $[60];
|
|
340
|
+
const handlePromoteArg = t19;
|
|
341
|
+
let t20;
|
|
342
|
+
if ($[61] !== applyDoc || $[62] !== applyVariables || $[63] !== operationName || $[64] !== schemaArgFor || $[65] !== variablesText || $[66] !== workingDoc) {
|
|
343
|
+
t20 = function handleDemoteArg(path_3, argName_2, varName_0) {
|
|
329
344
|
const vars_0 = readVariables(variablesText);
|
|
330
345
|
const jsValue_0 = vars_0[varName_0];
|
|
331
346
|
const schemaArg_1 = schemaArgFor(path_3, argName_2);
|
|
@@ -336,99 +351,99 @@ function useWorkingDocument() {
|
|
|
336
351
|
delete rest[varName_0];
|
|
337
352
|
applyVariables(rest);
|
|
338
353
|
};
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
$[
|
|
345
|
-
$[
|
|
346
|
-
} else
|
|
347
|
-
const handleDemoteArg =
|
|
348
|
-
let
|
|
349
|
-
if ($[
|
|
350
|
-
|
|
354
|
+
$[61] = applyDoc;
|
|
355
|
+
$[62] = applyVariables;
|
|
356
|
+
$[63] = operationName;
|
|
357
|
+
$[64] = schemaArgFor;
|
|
358
|
+
$[65] = variablesText;
|
|
359
|
+
$[66] = workingDoc;
|
|
360
|
+
$[67] = t20;
|
|
361
|
+
} else t20 = $[67];
|
|
362
|
+
const handleDemoteArg = t20;
|
|
363
|
+
let t21;
|
|
364
|
+
if ($[68] !== applyDoc || $[69] !== target || $[70] !== workingDoc) {
|
|
365
|
+
t21 = function handleAddInlineFragment(path_4, typeName) {
|
|
351
366
|
applyDoc(addInlineFragment(workingDoc, path_4, typeName, target));
|
|
352
367
|
};
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
357
|
-
} else
|
|
358
|
-
const handleAddInlineFragment =
|
|
359
|
-
let
|
|
360
|
-
if ($[
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
applyDoc(next_4);
|
|
364
|
-
reconcileVariablesJson(next_4);
|
|
365
|
-
};
|
|
366
|
-
$[74] = applyDoc;
|
|
367
|
-
$[75] = reconcileVariablesJson;
|
|
368
|
-
$[76] = target;
|
|
369
|
-
$[77] = workingDoc;
|
|
370
|
-
$[78] = t23;
|
|
371
|
-
} else t23 = $[78];
|
|
372
|
-
const handleRemoveInlineFragment = t23;
|
|
373
|
-
let t24;
|
|
374
|
-
if ($[79] !== applyDoc || $[80] !== reconcileVariablesJson || $[81] !== target || $[82] !== workingDoc) {
|
|
375
|
-
t24 = function handleRemoveFragmentSpread(path_6, fragmentName_0) {
|
|
376
|
-
const next_5 = removeFragmentSpread(workingDoc, path_6, fragmentName_0, target);
|
|
368
|
+
$[68] = applyDoc;
|
|
369
|
+
$[69] = target;
|
|
370
|
+
$[70] = workingDoc;
|
|
371
|
+
$[71] = t21;
|
|
372
|
+
} else t21 = $[71];
|
|
373
|
+
const handleAddInlineFragment = t21;
|
|
374
|
+
let t22;
|
|
375
|
+
if ($[72] !== applyDoc || $[73] !== reconcileVariablesJson || $[74] !== target || $[75] !== workingDoc) {
|
|
376
|
+
t22 = function handleRemoveInlineFragment(path_5, typeName_0) {
|
|
377
|
+
const next_5 = removeInlineFragment(workingDoc, path_5, typeName_0, target);
|
|
377
378
|
applyDoc(next_5);
|
|
378
379
|
reconcileVariablesJson(next_5);
|
|
379
380
|
};
|
|
380
|
-
$[
|
|
381
|
-
$[
|
|
382
|
-
$[
|
|
383
|
-
$[
|
|
384
|
-
$[
|
|
385
|
-
} else
|
|
386
|
-
const
|
|
387
|
-
let
|
|
388
|
-
if ($[
|
|
389
|
-
|
|
381
|
+
$[72] = applyDoc;
|
|
382
|
+
$[73] = reconcileVariablesJson;
|
|
383
|
+
$[74] = target;
|
|
384
|
+
$[75] = workingDoc;
|
|
385
|
+
$[76] = t22;
|
|
386
|
+
} else t22 = $[76];
|
|
387
|
+
const handleRemoveInlineFragment = t22;
|
|
388
|
+
let t23;
|
|
389
|
+
if ($[77] !== applyDoc || $[78] !== reconcileVariablesJson || $[79] !== target || $[80] !== workingDoc) {
|
|
390
|
+
t23 = function handleRemoveFragmentSpread(path_6, fragmentName_0) {
|
|
391
|
+
const next_6 = removeFragmentSpread(workingDoc, path_6, fragmentName_0, target);
|
|
392
|
+
applyDoc(next_6);
|
|
393
|
+
reconcileVariablesJson(next_6);
|
|
394
|
+
};
|
|
395
|
+
$[77] = applyDoc;
|
|
396
|
+
$[78] = reconcileVariablesJson;
|
|
397
|
+
$[79] = target;
|
|
398
|
+
$[80] = workingDoc;
|
|
399
|
+
$[81] = t23;
|
|
400
|
+
} else t23 = $[81];
|
|
401
|
+
const handleRemoveFragmentSpread = t23;
|
|
402
|
+
let t24;
|
|
403
|
+
if ($[82] !== applyDoc || $[83] !== target || $[84] !== workingDoc) {
|
|
404
|
+
t24 = function handleExtractFragment(path_7, typeName_1) {
|
|
390
405
|
const base = `${typeName_1}Fields`;
|
|
391
406
|
const existing = new Set(listFragments(workingDoc));
|
|
392
407
|
let name_1 = base;
|
|
393
408
|
for (let n = 2; existing.has(name_1); n++) name_1 = `${base}_${n}`;
|
|
394
409
|
applyDoc(createFragmentFromSelection(workingDoc, path_7, name_1, typeName_1, target));
|
|
395
410
|
};
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
$[
|
|
399
|
-
$[
|
|
400
|
-
} else
|
|
401
|
-
const handleExtractFragment =
|
|
402
|
-
let
|
|
403
|
-
if ($[
|
|
404
|
-
|
|
411
|
+
$[82] = applyDoc;
|
|
412
|
+
$[83] = target;
|
|
413
|
+
$[84] = workingDoc;
|
|
414
|
+
$[85] = t24;
|
|
415
|
+
} else t24 = $[85];
|
|
416
|
+
const handleExtractFragment = t24;
|
|
417
|
+
let t25;
|
|
418
|
+
if ($[86] !== applyDoc || $[87] !== workingDoc) {
|
|
419
|
+
t25 = function handleRenameFragment(oldName, newName) {
|
|
405
420
|
applyDoc(renameFragment(workingDoc, oldName, newName));
|
|
406
421
|
};
|
|
407
|
-
$[
|
|
408
|
-
$[
|
|
409
|
-
$[
|
|
410
|
-
} else
|
|
411
|
-
const handleRenameFragment =
|
|
412
|
-
let
|
|
413
|
-
if ($[
|
|
414
|
-
|
|
422
|
+
$[86] = applyDoc;
|
|
423
|
+
$[87] = workingDoc;
|
|
424
|
+
$[88] = t25;
|
|
425
|
+
} else t25 = $[88];
|
|
426
|
+
const handleRenameFragment = t25;
|
|
427
|
+
let t26;
|
|
428
|
+
if ($[89] !== activeFragment || $[90] !== applyDoc || $[91] !== moveCursorToTarget || $[92] !== operationName || $[93] !== workingDoc) {
|
|
429
|
+
t26 = function handleDeleteFragment(fragmentName_1) {
|
|
415
430
|
applyDoc(inlineFragment(workingDoc, fragmentName_1));
|
|
416
431
|
if (activeFragment === fragmentName_1) moveCursorToTarget({
|
|
417
432
|
kind: "operation",
|
|
418
433
|
name: operationName
|
|
419
434
|
});
|
|
420
435
|
};
|
|
421
|
-
$[
|
|
422
|
-
$[
|
|
423
|
-
$[
|
|
424
|
-
$[
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
} else
|
|
428
|
-
const handleDeleteFragment =
|
|
429
|
-
let
|
|
430
|
-
if ($[
|
|
431
|
-
|
|
436
|
+
$[89] = activeFragment;
|
|
437
|
+
$[90] = applyDoc;
|
|
438
|
+
$[91] = moveCursorToTarget;
|
|
439
|
+
$[92] = operationName;
|
|
440
|
+
$[93] = workingDoc;
|
|
441
|
+
$[94] = t26;
|
|
442
|
+
} else t26 = $[94];
|
|
443
|
+
const handleDeleteFragment = t26;
|
|
444
|
+
let t27;
|
|
445
|
+
if ($[95] !== activeOpKind || $[96] !== cursorPath || $[97] !== handleAddInlineFragment || $[98] !== handleBackToQuery || $[99] !== handleDeleteFragment || $[100] !== handleDemoteArg || $[101] !== handleExtractFragment || $[102] !== handleFocusFragment || $[103] !== handlePromoteArg || $[104] !== handleRemoveFragmentSpread || $[105] !== handleRemoveInlineFragment || $[106] !== handleRenameFragment || $[107] !== handleSetArg || $[108] !== handleToggle || $[109] !== target || $[110] !== workingDoc) {
|
|
446
|
+
t27 = {
|
|
432
447
|
workingDoc,
|
|
433
448
|
activeOpKind,
|
|
434
449
|
target,
|
|
@@ -446,25 +461,25 @@ function useWorkingDocument() {
|
|
|
446
461
|
handleRenameFragment,
|
|
447
462
|
handleDeleteFragment
|
|
448
463
|
};
|
|
449
|
-
$[
|
|
450
|
-
$[
|
|
451
|
-
$[
|
|
452
|
-
$[
|
|
453
|
-
$[
|
|
454
|
-
$[
|
|
455
|
-
$[
|
|
456
|
-
$[
|
|
457
|
-
$[
|
|
458
|
-
$[
|
|
459
|
-
$[
|
|
460
|
-
$[
|
|
461
|
-
$[
|
|
462
|
-
$[
|
|
463
|
-
$[
|
|
464
|
-
$[
|
|
465
|
-
$[
|
|
466
|
-
} else
|
|
467
|
-
return
|
|
464
|
+
$[95] = activeOpKind;
|
|
465
|
+
$[96] = cursorPath;
|
|
466
|
+
$[97] = handleAddInlineFragment;
|
|
467
|
+
$[98] = handleBackToQuery;
|
|
468
|
+
$[99] = handleDeleteFragment;
|
|
469
|
+
$[100] = handleDemoteArg;
|
|
470
|
+
$[101] = handleExtractFragment;
|
|
471
|
+
$[102] = handleFocusFragment;
|
|
472
|
+
$[103] = handlePromoteArg;
|
|
473
|
+
$[104] = handleRemoveFragmentSpread;
|
|
474
|
+
$[105] = handleRemoveInlineFragment;
|
|
475
|
+
$[106] = handleRenameFragment;
|
|
476
|
+
$[107] = handleSetArg;
|
|
477
|
+
$[108] = handleToggle;
|
|
478
|
+
$[109] = target;
|
|
479
|
+
$[110] = workingDoc;
|
|
480
|
+
$[111] = t27;
|
|
481
|
+
} else t27 = $[111];
|
|
482
|
+
return t27;
|
|
468
483
|
}
|
|
469
484
|
function _temp6(state_4) {
|
|
470
485
|
return state_4.tabs;
|
|
@@ -484,7 +499,6 @@ function _temp2(state_0) {
|
|
|
484
499
|
function _temp(state) {
|
|
485
500
|
return state.schema;
|
|
486
501
|
}
|
|
487
|
-
//#endregion
|
|
488
502
|
export { useWorkingDocument };
|
|
489
503
|
|
|
490
504
|
//# sourceMappingURL=use-working-document.js.map
|