@graphiql/plugin-doc-explorer 0.1.0 → 0.1.1-canary-9a1c125e.0
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/doc-explorer.js +113 -123
- package/dist/components/doc-explorer.js.map +1 -1
- package/dist/components/search.d.ts +1 -1
- package/dist/components/search.js +19 -32
- package/dist/components/search.js.map +1 -1
- package/dist/components/type-documentation.js +17 -26
- package/dist/components/type-documentation.js.map +1 -1
- package/dist/context.js +33 -43
- package/dist/context.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { isType } from "graphql";
|
|
4
|
-
import {
|
|
4
|
+
import { useSchemaStore, Spinner, ChevronLeftIcon } from "@graphiql/react";
|
|
5
5
|
import { useDocExplorer, useDocExplorerActions } from "../context.js";
|
|
6
6
|
import { FieldDocumentation } from "./field-documentation.js";
|
|
7
7
|
import { SchemaDocumentation } from "./schema-documentation.js";
|
|
@@ -9,108 +9,98 @@ import { Search } from "./search.js";
|
|
|
9
9
|
import { TypeDocumentation } from "./type-documentation.js";
|
|
10
10
|
/* empty css */
|
|
11
11
|
const DocExplorer = () => {
|
|
12
|
-
const $ = c(
|
|
13
|
-
let t0;
|
|
14
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
15
|
-
t0 = {
|
|
16
|
-
nonNull: true,
|
|
17
|
-
caller: DocExplorer
|
|
18
|
-
};
|
|
19
|
-
$[0] = t0;
|
|
20
|
-
} else {
|
|
21
|
-
t0 = $[0];
|
|
22
|
-
}
|
|
12
|
+
const $ = c(38);
|
|
23
13
|
const {
|
|
24
14
|
fetchError,
|
|
25
15
|
isFetching,
|
|
26
16
|
schema,
|
|
27
17
|
validationErrors
|
|
28
|
-
} =
|
|
18
|
+
} = useSchemaStore();
|
|
29
19
|
const explorerNavStack = useDocExplorer();
|
|
30
20
|
const {
|
|
31
21
|
pop
|
|
32
22
|
} = useDocExplorerActions();
|
|
33
23
|
let content;
|
|
34
24
|
let navItem;
|
|
35
|
-
if ($[
|
|
25
|
+
if ($[0] !== explorerNavStack || $[1] !== fetchError || $[2] !== isFetching || $[3] !== schema || $[4] !== validationErrors) {
|
|
36
26
|
navItem = explorerNavStack.at(-1);
|
|
37
27
|
content = null;
|
|
38
28
|
if (fetchError) {
|
|
39
|
-
let
|
|
40
|
-
if ($[
|
|
41
|
-
|
|
42
|
-
$[
|
|
29
|
+
let t02;
|
|
30
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
31
|
+
t02 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "Error fetching schema" });
|
|
32
|
+
$[7] = t02;
|
|
43
33
|
} else {
|
|
44
|
-
|
|
34
|
+
t02 = $[7];
|
|
45
35
|
}
|
|
46
|
-
content =
|
|
36
|
+
content = t02;
|
|
47
37
|
} else {
|
|
48
38
|
if (validationErrors.length > 0) {
|
|
49
|
-
let
|
|
50
|
-
if ($[
|
|
51
|
-
|
|
39
|
+
let t02;
|
|
40
|
+
if ($[8] !== validationErrors[0].message) {
|
|
41
|
+
t02 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-error", children: [
|
|
52
42
|
"Schema is invalid: ",
|
|
53
43
|
validationErrors[0].message
|
|
54
44
|
] });
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
45
|
+
$[8] = validationErrors[0].message;
|
|
46
|
+
$[9] = t02;
|
|
57
47
|
} else {
|
|
58
|
-
|
|
48
|
+
t02 = $[9];
|
|
59
49
|
}
|
|
60
|
-
content =
|
|
50
|
+
content = t02;
|
|
61
51
|
} else {
|
|
62
52
|
if (isFetching) {
|
|
63
|
-
let
|
|
64
|
-
if ($[
|
|
65
|
-
|
|
66
|
-
$[
|
|
53
|
+
let t02;
|
|
54
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
55
|
+
t02 = /* @__PURE__ */ jsx(Spinner, {});
|
|
56
|
+
$[10] = t02;
|
|
67
57
|
} else {
|
|
68
|
-
|
|
58
|
+
t02 = $[10];
|
|
69
59
|
}
|
|
70
|
-
content =
|
|
60
|
+
content = t02;
|
|
71
61
|
} else {
|
|
72
62
|
if (!schema) {
|
|
73
|
-
let
|
|
74
|
-
if ($[
|
|
75
|
-
|
|
76
|
-
$[
|
|
63
|
+
let t02;
|
|
64
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
65
|
+
t02 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "No GraphQL schema available" });
|
|
66
|
+
$[11] = t02;
|
|
77
67
|
} else {
|
|
78
|
-
|
|
68
|
+
t02 = $[11];
|
|
79
69
|
}
|
|
80
|
-
content =
|
|
70
|
+
content = t02;
|
|
81
71
|
} else {
|
|
82
72
|
if (explorerNavStack.length === 1) {
|
|
83
|
-
let
|
|
84
|
-
if ($[
|
|
85
|
-
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
73
|
+
let t02;
|
|
74
|
+
if ($[12] !== schema) {
|
|
75
|
+
t02 = /* @__PURE__ */ jsx(SchemaDocumentation, { schema });
|
|
76
|
+
$[12] = schema;
|
|
77
|
+
$[13] = t02;
|
|
88
78
|
} else {
|
|
89
|
-
|
|
79
|
+
t02 = $[13];
|
|
90
80
|
}
|
|
91
|
-
content =
|
|
81
|
+
content = t02;
|
|
92
82
|
} else {
|
|
93
83
|
if (isType(navItem.def)) {
|
|
94
|
-
let
|
|
95
|
-
if ($[
|
|
96
|
-
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
84
|
+
let t02;
|
|
85
|
+
if ($[14] !== navItem.def) {
|
|
86
|
+
t02 = /* @__PURE__ */ jsx(TypeDocumentation, { type: navItem.def });
|
|
87
|
+
$[14] = navItem.def;
|
|
88
|
+
$[15] = t02;
|
|
99
89
|
} else {
|
|
100
|
-
|
|
90
|
+
t02 = $[15];
|
|
101
91
|
}
|
|
102
|
-
content =
|
|
92
|
+
content = t02;
|
|
103
93
|
} else {
|
|
104
94
|
if (navItem.def) {
|
|
105
|
-
let
|
|
106
|
-
if ($[
|
|
107
|
-
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
95
|
+
let t02;
|
|
96
|
+
if ($[16] !== navItem.def) {
|
|
97
|
+
t02 = /* @__PURE__ */ jsx(FieldDocumentation, { field: navItem.def });
|
|
98
|
+
$[16] = navItem.def;
|
|
99
|
+
$[17] = t02;
|
|
110
100
|
} else {
|
|
111
|
-
|
|
101
|
+
t02 = $[17];
|
|
112
102
|
}
|
|
113
|
-
content =
|
|
103
|
+
content = t02;
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
106
|
}
|
|
@@ -118,105 +108,105 @@ const DocExplorer = () => {
|
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
110
|
}
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
111
|
+
$[0] = explorerNavStack;
|
|
112
|
+
$[1] = fetchError;
|
|
113
|
+
$[2] = isFetching;
|
|
114
|
+
$[3] = schema;
|
|
115
|
+
$[4] = validationErrors;
|
|
116
|
+
$[5] = content;
|
|
117
|
+
$[6] = navItem;
|
|
128
118
|
} else {
|
|
129
|
-
content = $[
|
|
130
|
-
navItem = $[
|
|
119
|
+
content = $[5];
|
|
120
|
+
navItem = $[6];
|
|
131
121
|
}
|
|
132
122
|
let prevName;
|
|
133
123
|
if (explorerNavStack.length > 1) {
|
|
134
|
-
let
|
|
135
|
-
if ($[
|
|
136
|
-
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
124
|
+
let t02;
|
|
125
|
+
if ($[18] !== explorerNavStack) {
|
|
126
|
+
t02 = explorerNavStack.at(-2);
|
|
127
|
+
$[18] = explorerNavStack;
|
|
128
|
+
$[19] = t02;
|
|
139
129
|
} else {
|
|
140
|
-
|
|
130
|
+
t02 = $[19];
|
|
141
131
|
}
|
|
142
|
-
prevName =
|
|
132
|
+
prevName = t02.name;
|
|
143
133
|
}
|
|
144
|
-
let
|
|
145
|
-
if ($[
|
|
146
|
-
|
|
134
|
+
let t0;
|
|
135
|
+
if ($[20] !== pop || $[21] !== prevName) {
|
|
136
|
+
t0 = prevName && /* @__PURE__ */ jsxs("a", { href: "#", className: "graphiql-doc-explorer-back", onClick: (event) => {
|
|
147
137
|
event.preventDefault();
|
|
148
138
|
pop();
|
|
149
139
|
}, "aria-label": `Go back to ${prevName}`, children: [
|
|
150
140
|
/* @__PURE__ */ jsx(ChevronLeftIcon, {}),
|
|
151
141
|
prevName
|
|
152
142
|
] });
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
143
|
+
$[20] = pop;
|
|
144
|
+
$[21] = prevName;
|
|
145
|
+
$[22] = t0;
|
|
156
146
|
} else {
|
|
157
|
-
|
|
147
|
+
t0 = $[22];
|
|
158
148
|
}
|
|
159
|
-
let
|
|
160
|
-
if ($[
|
|
161
|
-
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
149
|
+
let t1;
|
|
150
|
+
if ($[23] !== navItem.name) {
|
|
151
|
+
t1 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-title", children: navItem.name });
|
|
152
|
+
$[23] = navItem.name;
|
|
153
|
+
$[24] = t1;
|
|
164
154
|
} else {
|
|
165
|
-
|
|
155
|
+
t1 = $[24];
|
|
166
156
|
}
|
|
167
|
-
let
|
|
168
|
-
if ($[
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
157
|
+
let t2;
|
|
158
|
+
if ($[25] !== t0 || $[26] !== t1) {
|
|
159
|
+
t2 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header-content", children: [
|
|
160
|
+
t0,
|
|
161
|
+
t1
|
|
172
162
|
] });
|
|
163
|
+
$[25] = t0;
|
|
173
164
|
$[26] = t1;
|
|
174
165
|
$[27] = t2;
|
|
175
|
-
$[28] = t3;
|
|
176
166
|
} else {
|
|
177
|
-
|
|
167
|
+
t2 = $[27];
|
|
178
168
|
}
|
|
179
|
-
let
|
|
180
|
-
if ($[
|
|
181
|
-
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
169
|
+
let t3;
|
|
170
|
+
if ($[28] !== navItem.name) {
|
|
171
|
+
t3 = /* @__PURE__ */ jsx(Search, {}, navItem.name);
|
|
172
|
+
$[28] = navItem.name;
|
|
173
|
+
$[29] = t3;
|
|
184
174
|
} else {
|
|
185
|
-
|
|
175
|
+
t3 = $[29];
|
|
186
176
|
}
|
|
187
|
-
let
|
|
188
|
-
if ($[
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
177
|
+
let t4;
|
|
178
|
+
if ($[30] !== t2 || $[31] !== t3) {
|
|
179
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header", children: [
|
|
180
|
+
t2,
|
|
181
|
+
t3
|
|
192
182
|
] });
|
|
183
|
+
$[30] = t2;
|
|
193
184
|
$[31] = t3;
|
|
194
185
|
$[32] = t4;
|
|
195
|
-
$[33] = t5;
|
|
196
186
|
} else {
|
|
197
|
-
|
|
187
|
+
t4 = $[32];
|
|
198
188
|
}
|
|
199
|
-
let
|
|
200
|
-
if ($[
|
|
201
|
-
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
189
|
+
let t5;
|
|
190
|
+
if ($[33] !== content) {
|
|
191
|
+
t5 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-content", children: content });
|
|
192
|
+
$[33] = content;
|
|
193
|
+
$[34] = t5;
|
|
204
194
|
} else {
|
|
205
|
-
|
|
195
|
+
t5 = $[34];
|
|
206
196
|
}
|
|
207
|
-
let
|
|
208
|
-
if ($[
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
197
|
+
let t6;
|
|
198
|
+
if ($[35] !== t4 || $[36] !== t5) {
|
|
199
|
+
t6 = /* @__PURE__ */ jsxs("section", { className: "graphiql-doc-explorer", "aria-label": "Documentation Explorer", children: [
|
|
200
|
+
t4,
|
|
201
|
+
t5
|
|
212
202
|
] });
|
|
203
|
+
$[35] = t4;
|
|
213
204
|
$[36] = t5;
|
|
214
205
|
$[37] = t6;
|
|
215
|
-
$[38] = t7;
|
|
216
206
|
} else {
|
|
217
|
-
|
|
207
|
+
t6 = $[37];
|
|
218
208
|
}
|
|
219
|
-
return
|
|
209
|
+
return t6;
|
|
220
210
|
};
|
|
221
211
|
export {
|
|
222
212
|
DocExplorer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-explorer.js","sources":["../../src/components/doc-explorer.tsx"],"sourcesContent":["import { isType } from 'graphql';\nimport { FC, ReactNode } from 'react';\nimport { ChevronLeftIcon, Spinner,
|
|
1
|
+
{"version":3,"file":"doc-explorer.js","sources":["../../src/components/doc-explorer.tsx"],"sourcesContent":["import { isType } from 'graphql';\nimport { FC, ReactNode } from 'react';\nimport { ChevronLeftIcon, Spinner, useSchemaStore } from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { FieldDocumentation } from './field-documentation';\nimport { SchemaDocumentation } from './schema-documentation';\nimport { Search } from './search';\nimport { TypeDocumentation } from './type-documentation';\nimport './doc-explorer.css';\n\nexport const DocExplorer: FC = () => {\n const { fetchError, isFetching, schema, validationErrors } = useSchemaStore();\n const explorerNavStack = useDocExplorer();\n const { pop } = useDocExplorerActions();\n const navItem = explorerNavStack.at(-1)!;\n\n let content: ReactNode = null;\n if (fetchError) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">Error fetching schema</div>\n );\n } else if (validationErrors.length > 0) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n Schema is invalid: {validationErrors[0].message}\n </div>\n );\n } else if (isFetching) {\n // Schema is undefined when it is being loaded via introspection.\n content = <Spinner />;\n } else if (!schema) {\n // Schema is null when it explicitly does not exist, typically due to\n // an error during introspection.\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n No GraphQL schema available\n </div>\n );\n } else if (explorerNavStack.length === 1) {\n content = <SchemaDocumentation schema={schema} />;\n } else if (isType(navItem.def)) {\n content = <TypeDocumentation type={navItem.def} />;\n } else if (navItem.def) {\n content = <FieldDocumentation field={navItem.def} />;\n }\n\n let prevName;\n if (explorerNavStack.length > 1) {\n prevName = explorerNavStack.at(-2)!.name;\n }\n\n return (\n <section\n className=\"graphiql-doc-explorer\"\n aria-label=\"Documentation Explorer\"\n >\n <div className=\"graphiql-doc-explorer-header\">\n <div className=\"graphiql-doc-explorer-header-content\">\n {prevName && (\n <a\n href=\"#\"\n className=\"graphiql-doc-explorer-back\"\n onClick={event => {\n event.preventDefault();\n pop();\n }}\n aria-label={`Go back to ${prevName}`}\n >\n <ChevronLeftIcon />\n {prevName}\n </a>\n )}\n <div className=\"graphiql-doc-explorer-title\">{navItem.name}</div>\n </div>\n <Search key={navItem.name} />\n </div>\n <div className=\"graphiql-doc-explorer-content\">{content}</div>\n </section>\n );\n};\n"],"names":["DocExplorer","$","_c","fetchError","isFetching","schema","validationErrors","useSchemaStore","explorerNavStack","useDocExplorer","pop","useDocExplorerActions","content","navItem","at","t0","Symbol","for","length","message","isType","def","prevName","event","preventDefault","t1","name","t2","t3","t4","t5","t6"],"mappings":";;;;;;;;;;AAUO,MAAMA,cAAkBA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAC7B,QAAA;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,MAA6DC,eAAe;AAC5E,QAAAC,mBAAyBC,eAAe;AACxC,QAAA;AAAA,IAAAC;AAAAA,MAAgBC,sBAAsB;AAAEC,MAAAA;AAAAC,MAAAA;AAAA,MAAAZ,EAAAO,CAAAA,MAAAA,oBAAAP,EAAA,CAAA,MAAAE,cAAAF,EAAAG,CAAAA,MAAAA,cAAAH,EAAA,CAAA,MAAAI,UAAAJ,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,EAAAA,OAAA;AAAAA,SAAA3B,EAAA,EAAA;AAAA,EAAA;AAAA4B,MAAAA;AAAA,MAAA5B,EAAA0B,EAAAA,MAAAA,MAAA1B,UAAA2B,IAAA;AACzB,SAAA,qBAAA,OAnBS,EAAA,WAAA,gCACbD,UAAAA;AAAAA,MAAAA;AAAAA,MAiBAC;AAAAA,IAAAA,GACF;AAAM3B,YAAA0B;AAAA1B,YAAA2B;AAAA3B,YAAA4B;AAAAA,EAAAA,OAAA;AAAAA,SAAA5B,EAAA,EAAA;AAAA,EAAA;AAAA6B,MAAAA;AAAA7B,MAAAA,UAAAW,SAAA;AACNkB,SAAA,oBAAA,OAAA,EAAe,WAAA,iCAAiClB,UAAQ,SAAA;AAAMX,YAAAW;AAAAX,YAAA6B;AAAAA,EAAAA,OAAA;AAAAA,SAAA7B,EAAA,EAAA;AAAA,EAAA;AAAA8B,MAAAA;AAAA,MAAA9B,EAAA4B,EAAAA,MAAAA,MAAA5B,UAAA6B,IAAA;AAxBhEC,2CACY,WAAA,yBACC,cAAA,0BAEXF,UAAAA;AAAAA,MAAAA;AAAAA,MAoBAC;AAAAA,IAAAA,GACF;AAAU7B,YAAA4B;AAAA5B,YAAA6B;AAAA7B,YAAA8B;AAAAA,EAAAA,OAAA;AAAAA,SAAA9B,EAAA,EAAA;AAAA,EAAA;AAzBV8B,SAAAA;AAyBU;"}
|
|
@@ -9,7 +9,7 @@ declare type FieldMatch = {
|
|
|
9
9
|
field: GraphQLField<unknown, unknown> | GraphQLInputField;
|
|
10
10
|
argument?: GraphQLArgument;
|
|
11
11
|
};
|
|
12
|
-
export declare function useSearchResults(
|
|
12
|
+
export declare function useSearchResults(): (searchValue: string) => {
|
|
13
13
|
within: FieldMatch[];
|
|
14
14
|
types: TypeMatch[];
|
|
15
15
|
fields: FieldMatch[];
|
|
@@ -3,7 +3,7 @@ import { c } from "react-compiler-runtime";
|
|
|
3
3
|
import { isObjectType, isInterfaceType, isInputObjectType } from "graphql";
|
|
4
4
|
import { useRef, useState, useEffect } from "react";
|
|
5
5
|
import { ComboboxOptions, ComboboxOption, ComboboxInput, Combobox } from "@headlessui/react";
|
|
6
|
-
import { debounce,
|
|
6
|
+
import { debounce, useSchemaStore, MagnifyingGlassIcon, isMacOs } from "@graphiql/react";
|
|
7
7
|
import { useDocExplorer, useDocExplorerActions } from "../context.js";
|
|
8
8
|
import { renderType } from "./utils.js";
|
|
9
9
|
/* empty css */
|
|
@@ -176,37 +176,24 @@ const Search = () => {
|
|
|
176
176
|
}
|
|
177
177
|
return t14;
|
|
178
178
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const $ = c(7);
|
|
179
|
+
function useSearchResults() {
|
|
180
|
+
const $ = c(5);
|
|
182
181
|
const explorerNavStack = useDocExplorer();
|
|
183
|
-
const t0 = caller || _useSearchResults;
|
|
184
|
-
let t1;
|
|
185
|
-
if ($[0] !== t0) {
|
|
186
|
-
t1 = {
|
|
187
|
-
nonNull: true,
|
|
188
|
-
caller: t0
|
|
189
|
-
};
|
|
190
|
-
$[0] = t0;
|
|
191
|
-
$[1] = t1;
|
|
192
|
-
} else {
|
|
193
|
-
t1 = $[1];
|
|
194
|
-
}
|
|
195
182
|
const {
|
|
196
183
|
schema
|
|
197
|
-
} =
|
|
198
|
-
let
|
|
199
|
-
if ($[
|
|
200
|
-
|
|
201
|
-
$[
|
|
202
|
-
$[
|
|
184
|
+
} = useSchemaStore();
|
|
185
|
+
let t0;
|
|
186
|
+
if ($[0] !== explorerNavStack) {
|
|
187
|
+
t0 = explorerNavStack.at(-1);
|
|
188
|
+
$[0] = explorerNavStack;
|
|
189
|
+
$[1] = t0;
|
|
203
190
|
} else {
|
|
204
|
-
|
|
191
|
+
t0 = $[1];
|
|
205
192
|
}
|
|
206
|
-
const navItem =
|
|
207
|
-
let
|
|
208
|
-
if ($[
|
|
209
|
-
|
|
193
|
+
const navItem = t0;
|
|
194
|
+
let t1;
|
|
195
|
+
if ($[2] !== navItem || $[3] !== schema) {
|
|
196
|
+
t1 = (searchValue) => {
|
|
210
197
|
const matches = {
|
|
211
198
|
within: [],
|
|
212
199
|
types: [],
|
|
@@ -261,13 +248,13 @@ function useSearchResults(caller) {
|
|
|
261
248
|
}
|
|
262
249
|
return matches;
|
|
263
250
|
};
|
|
264
|
-
$[
|
|
265
|
-
$[
|
|
266
|
-
$[
|
|
251
|
+
$[2] = navItem;
|
|
252
|
+
$[3] = schema;
|
|
253
|
+
$[4] = t1;
|
|
267
254
|
} else {
|
|
268
|
-
|
|
255
|
+
t1 = $[4];
|
|
269
256
|
}
|
|
270
|
-
return
|
|
257
|
+
return t1;
|
|
271
258
|
}
|
|
272
259
|
function isMatch(sourceText, searchValue) {
|
|
273
260
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sources":["../../src/components/search.tsx"],"sourcesContent":["import {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from 'graphql';\nimport { FC, useEffect, useRef, useState } from 'react';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n isMacOs,\n useSchemaContext,\n MagnifyingGlassIcon,\n debounce,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './search.css';\n\nexport const Search: FC = () => {\n const explorerNavStack = useDocExplorer();\n const { push } = useDocExplorerActions();\n\n const inputRef = useRef<HTMLInputElement>(null!);\n const getSearchResults = useSearchResults();\n const [searchValue, setSearchValue] = useState('');\n const [results, setResults] = useState(() => getSearchResults(searchValue));\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\n // Workaround to fix React compiler error:\n // Ref values (the `current` property) may not be accessed during render.\n const [ref] = useState(inputRef);\n const isFocused = ref.current === document.activeElement;\n\n useEffect(() => {\n debouncedGetSearchResults(searchValue);\n }, [debouncedGetSearchResults, searchValue]);\n\n useEffect(() => {\n function handleKeyDown(event: KeyboardEvent) {\n if (event.metaKey && event.key === 'k') {\n inputRef.current.focus();\n }\n }\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, []);\n\n const navItem = explorerNavStack.at(-1)!;\n\n const onSelect = (def: TypeMatch | FieldMatch) => {\n push(\n 'field' in def\n ? { name: def.field.name, def: def.field }\n : { name: def.type.name, def: def.type },\n );\n };\n const shouldSearchBoxAppear =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n if (!shouldSearchBoxAppear) {\n return null;\n }\n\n return (\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search\"\n onChange={onSelect}\n data-state={isFocused ? undefined : 'idle'}\n aria-label={`Search ${navItem.name}...`}\n >\n <div\n className=\"graphiql-doc-explorer-search-input\"\n onClick={() => {\n inputRef.current.focus();\n }}\n >\n <MagnifyingGlassIcon />\n <ComboboxInput\n autoComplete=\"off\"\n onChange={event => setSearchValue(event.target.value)}\n placeholder={`${isMacOs ? '⌘' : 'Ctrl'} K`}\n ref={inputRef}\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n />\n </div>\n {isFocused && (\n <ComboboxOptions data-cy=\"doc-explorer-list\">\n {results.within.length +\n results.types.length +\n results.fields.length ===\n 0 ? (\n <li className=\"graphiql-doc-explorer-search-empty\">\n No results found\n </li>\n ) : (\n results.within.map((result, i) => (\n <ComboboxOption\n key={`within-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))\n )}\n {results.within.length > 0 &&\n results.types.length + results.fields.length > 0 ? (\n <div className=\"graphiql-doc-explorer-search-divider\">\n Other results\n </div>\n ) : null}\n {results.types.map((result, i) => (\n <ComboboxOption\n key={`type-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Type type={result.type} />\n </ComboboxOption>\n ))}\n {results.fields.map((result, i) => (\n <ComboboxOption\n key={`field-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Type type={result.type} />.\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n );\n};\n\ntype TypeMatch = { type: GraphQLNamedType };\n\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\n// To make react-compiler happy, otherwise complains about - Hooks may not be referenced as normal values\nconst _useSearchResults = useSearchResults;\n\nexport function useSearchResults(caller?: Function) {\n const explorerNavStack = useDocExplorer();\n const { schema } = useSchemaContext({\n nonNull: true,\n caller: caller || _useSearchResults,\n });\n\n const navItem = explorerNavStack.at(-1)!;\n\n return (searchValue: string) => {\n const matches: {\n within: FieldMatch[];\n types: TypeMatch[];\n fields: FieldMatch[];\n } = {\n within: [],\n types: [],\n fields: [],\n };\n\n if (!schema) {\n return matches;\n }\n\n const withinType = navItem.def;\n\n const typeMap = schema.getTypeMap();\n let typeNames = Object.keys(typeMap);\n\n // Move the within type name to be the first searched.\n if (withinType) {\n typeNames = typeNames.filter(n => n !== withinType.name);\n typeNames.unshift(withinType.name);\n }\n for (const typeName of typeNames) {\n if (\n matches.within.length + matches.types.length + matches.fields.length >=\n 100\n ) {\n break;\n }\n\n const type = typeMap[typeName];\n if (withinType !== type && isMatch(typeName, searchValue)) {\n matches.types.push({ type });\n }\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n continue;\n }\n\n const fields = type.getFields();\n for (const fieldName in fields) {\n const field = fields[fieldName];\n let matchingArgs: GraphQLArgument[] | undefined;\n\n if (!isMatch(fieldName, searchValue)) {\n if ('args' in field) {\n matchingArgs = field.args.filter(arg =>\n isMatch(arg.name, searchValue),\n );\n if (matchingArgs.length === 0) {\n continue;\n }\n } else {\n continue;\n }\n }\n\n matches[withinType === type ? 'within' : 'fields'].push(\n ...(matchingArgs\n ? matchingArgs.map(argument => ({ type, field, argument }))\n : [{ type, field }]),\n );\n }\n }\n\n return matches;\n };\n}\n\nfunction isMatch(sourceText: string, searchValue: string): boolean {\n try {\n const escaped = searchValue.replaceAll(/[^_0-9A-Za-z]/g, ch => '\\\\' + ch);\n return new RegExp(escaped, 'i').test(sourceText);\n } catch {\n return sourceText.toLowerCase().includes(searchValue.toLowerCase());\n }\n}\n\nconst Type: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n return <span className=\"graphiql-doc-explorer-search-type\">{type.name}</span>;\n};\n\ntype FieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst Field: FC<FieldProps> = ({ field, argument }) => {\n return (\n <>\n <span className=\"graphiql-doc-explorer-search-field\">{field.name}</span>\n {argument ? (\n <>\n (\n <span className=\"graphiql-doc-explorer-search-argument\">\n {argument.name}\n </span>\n :{' '}\n {renderType(argument.type, namedType => (\n <Type type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"names":["Search","$","_c","explorerNavStack","useDocExplorer","push","useDocExplorerActions","inputRef","useRef","getSearchResults","useSearchResults","searchValue","setSearchValue","useState","t0","results","setResults","t1","debounce","search","debouncedGetSearchResults","ref","isFocused","current","document","activeElement","t2","t3","useEffect","t4","t5","Symbol","for","handleKeyDown","event","metaKey","key","focus","addEventListener","window","removeEventListener","navItem","onSelect","t6","at","t7","def","name","field","type","length","isObjectType","isInterfaceType","isInputObjectType","shouldSearchBoxAppear","undefined","t8","t10","t9","t11","event_0","target","value","t12","isMacOs","t13","within","types","fields","map","_temp","_temp2","_temp3","t14","_useSearchResults","caller","nonNull","schema","useSchemaContext","matches","withinType","typeMap","getTypeMap","typeNames","Object","keys","filter","n","unshift","typeName","isMatch","getFields","fieldName","matchingArgs","args","arg","argument","sourceText","escaped","replaceAll","ch","RegExp","test","toLowerCase","includes","Type","Field","renderType","_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AgB,CAAAA,MAAAA,MAAAhB,SAAAyB,IAAA;AAdVC,SACEV,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA;AAAAA,MACCS;AAAAA,IAAAA,GAYO;AACPzB,WAAAgB;AAAAhB,WAAAyB;AAAAzB,WAAA0B;AAAAA,EAAAA,OAAA;AAAAA,SAAA1B,EAAA,CAAA;AAAA,EAAA;AAfH0B,SAAAA;AAeG;AA/PmB,SAAA2C,MAAAuC,QAAAC,GAAA;AAAA,6BAoFX,gBAEQD,EAAAA,OAAK,QACJ,WAAA,uBAER,UAAC,oBAAA,OAAA,EAAa,OAAAA,OAAM7D,OAAkB,UAAA6D,OAAMb,UAC9C,EALO,GAAA,UAAUc,CAAC,EAKlB;AAAiB;AA1FL,SAAAvC,OAAAwC,UAAAC,KAAA;AAAA,SAoGb,oBAAA,gBAAA,EAEQH,OAAAA,UACC,WAAA,uBAER,UAAA,oBAAC,MAAW,EAAA,MAAAA,SAAM5D,KACpB,CAAA,EALe6D,GAAAA,QAAAA,GAAC,EAKhB;AAAiB;AA1GH,SAAAtC,OAAAyC,UAAAC,KAAA;AAAA,SA6Gb,qBAAA,gBAAA,EAEQL,iBACC,WAAA,uBAER,UAAA;AAAA,IAAC,oBAAA,MAAA,EAAW,MAAAA,SAAM5D,KAAS,CAAA;AAAA,IAAA;AAAA,wBAC1B,OAAa,EAAA,OAAA4D,SAAM7D,OAAkB,UAAA6D,SAAMb,SAAS,CAAA;AAAA,gBALvCc,GAAC,EAMjB;AAAiB;AA0HC,SAAAF,OAAAO,WAAA;AAYlB,SAAA,oBAAC,MAAWA,EAAAA,MAAAA,UAAa,CAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"search.js","sources":["../../src/components/search.tsx"],"sourcesContent":["import {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from 'graphql';\nimport { FC, useEffect, useRef, useState } from 'react';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n isMacOs,\n useSchemaStore,\n MagnifyingGlassIcon,\n debounce,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './search.css';\n\nexport const Search: FC = () => {\n const explorerNavStack = useDocExplorer();\n const { push } = useDocExplorerActions();\n\n const inputRef = useRef<HTMLInputElement>(null!);\n const getSearchResults = useSearchResults();\n const [searchValue, setSearchValue] = useState('');\n const [results, setResults] = useState(() => getSearchResults(searchValue));\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\n // Workaround to fix React compiler error:\n // Ref values (the `current` property) may not be accessed during render.\n const [ref] = useState(inputRef);\n const isFocused = ref.current === document.activeElement;\n\n useEffect(() => {\n debouncedGetSearchResults(searchValue);\n }, [debouncedGetSearchResults, searchValue]);\n\n useEffect(() => {\n function handleKeyDown(event: KeyboardEvent) {\n if (event.metaKey && event.key === 'k') {\n inputRef.current.focus();\n }\n }\n\n window.addEventListener('keydown', handleKeyDown);\n return () => window.removeEventListener('keydown', handleKeyDown);\n }, []);\n\n const navItem = explorerNavStack.at(-1)!;\n\n const onSelect = (def: TypeMatch | FieldMatch) => {\n push(\n 'field' in def\n ? { name: def.field.name, def: def.field }\n : { name: def.type.name, def: def.type },\n );\n };\n const shouldSearchBoxAppear =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n if (!shouldSearchBoxAppear) {\n return null;\n }\n\n return (\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search\"\n onChange={onSelect}\n data-state={isFocused ? undefined : 'idle'}\n aria-label={`Search ${navItem.name}...`}\n >\n <div\n className=\"graphiql-doc-explorer-search-input\"\n onClick={() => {\n inputRef.current.focus();\n }}\n >\n <MagnifyingGlassIcon />\n <ComboboxInput\n autoComplete=\"off\"\n onChange={event => setSearchValue(event.target.value)}\n placeholder={`${isMacOs ? '⌘' : 'Ctrl'} K`}\n ref={inputRef}\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n />\n </div>\n {isFocused && (\n <ComboboxOptions data-cy=\"doc-explorer-list\">\n {results.within.length +\n results.types.length +\n results.fields.length ===\n 0 ? (\n <li className=\"graphiql-doc-explorer-search-empty\">\n No results found\n </li>\n ) : (\n results.within.map((result, i) => (\n <ComboboxOption\n key={`within-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))\n )}\n {results.within.length > 0 &&\n results.types.length + results.fields.length > 0 ? (\n <div className=\"graphiql-doc-explorer-search-divider\">\n Other results\n </div>\n ) : null}\n {results.types.map((result, i) => (\n <ComboboxOption\n key={`type-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Type type={result.type} />\n </ComboboxOption>\n ))}\n {results.fields.map((result, i) => (\n <ComboboxOption\n key={`field-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <Type type={result.type} />.\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n );\n};\n\ntype TypeMatch = { type: GraphQLNamedType };\n\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nexport function useSearchResults() {\n const explorerNavStack = useDocExplorer();\n const { schema } = useSchemaStore();\n\n const navItem = explorerNavStack.at(-1)!;\n\n return (searchValue: string) => {\n const matches: {\n within: FieldMatch[];\n types: TypeMatch[];\n fields: FieldMatch[];\n } = {\n within: [],\n types: [],\n fields: [],\n };\n\n if (!schema) {\n return matches;\n }\n\n const withinType = navItem.def;\n\n const typeMap = schema.getTypeMap();\n let typeNames = Object.keys(typeMap);\n\n // Move the within type name to be the first searched.\n if (withinType) {\n typeNames = typeNames.filter(n => n !== withinType.name);\n typeNames.unshift(withinType.name);\n }\n for (const typeName of typeNames) {\n if (\n matches.within.length + matches.types.length + matches.fields.length >=\n 100\n ) {\n break;\n }\n\n const type = typeMap[typeName];\n if (withinType !== type && isMatch(typeName, searchValue)) {\n matches.types.push({ type });\n }\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n continue;\n }\n\n const fields = type.getFields();\n for (const fieldName in fields) {\n const field = fields[fieldName];\n let matchingArgs: GraphQLArgument[] | undefined;\n\n if (!isMatch(fieldName, searchValue)) {\n if ('args' in field) {\n matchingArgs = field.args.filter(arg =>\n isMatch(arg.name, searchValue),\n );\n if (matchingArgs.length === 0) {\n continue;\n }\n } else {\n continue;\n }\n }\n\n matches[withinType === type ? 'within' : 'fields'].push(\n ...(matchingArgs\n ? matchingArgs.map(argument => ({ type, field, argument }))\n : [{ type, field }]),\n );\n }\n }\n\n return matches;\n };\n}\n\nfunction isMatch(sourceText: string, searchValue: string): boolean {\n try {\n const escaped = searchValue.replaceAll(/[^_0-9A-Za-z]/g, ch => '\\\\' + ch);\n return new RegExp(escaped, 'i').test(sourceText);\n } catch {\n return sourceText.toLowerCase().includes(searchValue.toLowerCase());\n }\n}\n\nconst Type: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n return <span className=\"graphiql-doc-explorer-search-type\">{type.name}</span>;\n};\n\ntype FieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst Field: FC<FieldProps> = ({ field, argument }) => {\n return (\n <>\n <span className=\"graphiql-doc-explorer-search-field\">{field.name}</span>\n {argument ? (\n <>\n (\n <span className=\"graphiql-doc-explorer-search-argument\">\n {argument.name}\n </span>\n :{' '}\n {renderType(argument.type, namedType => (\n <Type type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"names":["Search","$","_c","explorerNavStack","useDocExplorer","push","useDocExplorerActions","inputRef","useRef","getSearchResults","useSearchResults","searchValue","setSearchValue","useState","t0","results","setResults","t1","debounce","search","debouncedGetSearchResults","ref","isFocused","current","document","activeElement","t2","t3","useEffect","t4","t5","Symbol","for","handleKeyDown","event","metaKey","key","focus","addEventListener","window","removeEventListener","navItem","onSelect","t6","at","t7","def","name","field","type","length","isObjectType","isInterfaceType","isInputObjectType","shouldSearchBoxAppear","undefined","t8","t10","t9","t11","event_0","target","value","t12","isMacOs","t13","within","types","fields","map","_temp","_temp2","_temp3","t14","schema","useSchemaStore","matches","withinType","typeMap","getTypeMap","typeNames","Object","keys","filter","n","unshift","typeName","isMatch","getFields","fieldName","matchingArgs","args","arg","argument","sourceText","escaped","replaceAll","ch","RegExp","test","toLowerCase","includes","Type","Field","renderType","_temp4","result","i","result_0","i_0","result_1","i_1","namedType"],"mappings":";;;;;;;;;AA0BO,MAAMA,SAAaA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AACxB,QAAAC,mBAAyBC,eAAe;AACxC,QAAA;AAAA,IAAAC;AAAAA,MAAiBC,sBAAsB;AAEvCC,QAAAA,WAAiBC,OAAA,IAA8B;AAC/C,QAAAC,mBAAyBC,iBAAiB;AAC1C,QAAA,CAAAC,aAAAC,cAAA,IAAsCC,SAAS,EAAE;AAAEC,MAAAA;AAAA,MAAAb,EAAAQ,CAAAA,MAAAA,oBAAAR,SAAAU,aAAA;AACZG,SAAAA,MAAML,iBAAiBE,WAAW;AAACV,WAAAQ;AAAAR,WAAAU;AAAAV,WAAAa;AAAAA,EAAAA,OAAA;AAAAA,SAAAb,EAAA,CAAA;AAAA,EAAA;AAA1E,QAAA,CAAAc,SAAAC,UAAA,IAA8BH,SAASC,EAAmC;AAAEG,MAAAA;AAAAhB,MAAAA,SAAAQ,kBAAA;AAC1CS,SAAAA,SAAA,KAAAC,CAAA,WAAA;AACrBV,iBAAAA,iBAAiBU,MAAM,CAAC;AAAA,IAAA,CACpC;AAAClB,WAAAQ;AAAAR,WAAAgB;AAAAA,EAAAA,OAAA;AAAAA,SAAAhB,EAAA,CAA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
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { isNamedType, isObjectType, isInterfaceType, isInputObjectType, isEnumType, isAbstractType } from "graphql";
|
|
5
|
-
import { MarkdownContent, Button,
|
|
5
|
+
import { MarkdownContent, Button, useSchemaStore } from "@graphiql/react";
|
|
6
6
|
import { Argument } from "./argument.js";
|
|
7
7
|
import { DefaultValue } from "./default-value.js";
|
|
8
8
|
import { DeprecationReason } from "./deprecation-reason.js";
|
|
@@ -330,45 +330,36 @@ const EnumValue = (t0) => {
|
|
|
330
330
|
return t4;
|
|
331
331
|
};
|
|
332
332
|
const PossibleTypes = (t0) => {
|
|
333
|
-
const $ = c(
|
|
333
|
+
const $ = c(6);
|
|
334
334
|
const {
|
|
335
335
|
type
|
|
336
336
|
} = t0;
|
|
337
|
-
let t1;
|
|
338
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
339
|
-
t1 = {
|
|
340
|
-
nonNull: true
|
|
341
|
-
};
|
|
342
|
-
$[0] = t1;
|
|
343
|
-
} else {
|
|
344
|
-
t1 = $[0];
|
|
345
|
-
}
|
|
346
337
|
const {
|
|
347
338
|
schema
|
|
348
|
-
} =
|
|
339
|
+
} = useSchemaStore();
|
|
349
340
|
if (!schema || !isAbstractType(type)) {
|
|
350
341
|
return null;
|
|
351
342
|
}
|
|
352
|
-
const
|
|
353
|
-
let
|
|
354
|
-
if ($[
|
|
355
|
-
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
358
|
-
$[
|
|
343
|
+
const t1 = isInterfaceType(type) ? "Implementations" : "Possible Types";
|
|
344
|
+
let t2;
|
|
345
|
+
if ($[0] !== schema || $[1] !== type) {
|
|
346
|
+
t2 = schema.getPossibleTypes(type).map(_temp7);
|
|
347
|
+
$[0] = schema;
|
|
348
|
+
$[1] = type;
|
|
349
|
+
$[2] = t2;
|
|
359
350
|
} else {
|
|
360
|
-
|
|
351
|
+
t2 = $[2];
|
|
361
352
|
}
|
|
362
|
-
let
|
|
363
|
-
if ($[
|
|
364
|
-
|
|
353
|
+
let t3;
|
|
354
|
+
if ($[3] !== t1 || $[4] !== t2) {
|
|
355
|
+
t3 = /* @__PURE__ */ jsx(ExplorerSection, { title: t1, children: t2 });
|
|
356
|
+
$[3] = t1;
|
|
365
357
|
$[4] = t2;
|
|
366
358
|
$[5] = t3;
|
|
367
|
-
$[6] = t4;
|
|
368
359
|
} else {
|
|
369
|
-
|
|
360
|
+
t3 = $[5];
|
|
370
361
|
}
|
|
371
|
-
return
|
|
362
|
+
return t3;
|
|
372
363
|
};
|
|
373
364
|
function _temp(implementedInterface) {
|
|
374
365
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TypeLink, { type: implementedInterface }) }, implementedInterface.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-documentation.js","sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useSchemaContext, Button, MarkdownContent } from '@graphiql/react';\nimport { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({ type }) => {\n return isNamedType(type) ? (\n <>\n {type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n <ImplementsInterfaces type={type} />\n <Fields type={type} />\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name])) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 ? (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedValues.length > 0 ? (\n showDeprecated || values.length === 0 ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description ? (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n ) : null}\n {value.deprecationReason ? (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n ) : null}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const { schema } = useSchemaContext({ nonNull: true });\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"names":["TypeDocumentation","t0","$","_c","type","t1","isNamedType","description","ImplementsInterfaces","isObjectType","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","useState","Symbol","for","handleShowDeprecated","isInterfaceType","isInputObjectType","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","isEnumType","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","nonNull","schema","useSchemaContext","isAbstractType","getPossibleTypes","_temp7","implementedInterface","field_0","field_1","value_0","value_1","possibleType"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,oBAAgDC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAAQI,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAC7DE,SAAAA,YAAYF,IAAI,IAElBA,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA,KAAIG,cACF,oBAAA,iBAAA,EAAqB,MAAA,eAAeH,UAAAA,KAAIG,aAAa,IACjD;AAAA,MACP,oBAAC,wBAA2BH,MAAI;AAAA,MAChC,oBAAC,UAAaA,MAAI;AAAA,MAClB,oBAAC,cAAiBA,MAAI;AAAA,MACtB,oBAAC,iBAAoBA,KAAI,CAAA;AAAA,IAAA,EAAA,CAAI,IAEzB;AAAAF,WAAAE;AAAAF,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAVDG,SAAAA;AAUC;AAGV,MAAMG,uBAAuDP,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,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SAAAiC,OAAAM,cAAA;AAU9C,SAAA,6BACE,UAAC,oBAAA,UAAA,EAAeA,mBAAY,CAAA,KADpBA,aAAYvC,IAEtB;AAAM;"}
|
|
1
|
+
{"version":3,"file":"type-documentation.js","sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useSchemaStore, Button, MarkdownContent } from '@graphiql/react';\nimport { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({ type }) => {\n return isNamedType(type) ? (\n <>\n {type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n <ImplementsInterfaces type={type} />\n <Fields type={type} />\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name])) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 ? (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedValues.length > 0 ? (\n showDeprecated || values.length === 0 ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description ? (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n ) : null}\n {value.deprecationReason ? (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n ) : null}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const { schema } = useSchemaStore();\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"names":["TypeDocumentation","t0","$","_c","type","t1","isNamedType","description","ImplementsInterfaces","isObjectType","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","useState","Symbol","for","handleShowDeprecated","isInterfaceType","isInputObjectType","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","isEnumType","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","schema","useSchemaStore","isAbstractType","getPossibleTypes","_temp7","implementedInterface","field_0","field_1","value_0","value_1","possibleType"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,oBAAgDC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAAQI,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAC7DE,SAAAA,YAAYF,IAAI,IAElBA,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA,KAAIG,cACF,oBAAA,iBAAA,EAAqB,MAAA,eAAeH,UAAAA,KAAIG,aAAa,IACjD;AAAA,MACP,oBAAC,wBAA2BH,MAAI;AAAA,MAChC,oBAAC,UAAaA,MAAI;AAAA,MAClB,oBAAC,cAAiBA,MAAI;AAAA,MACtB,oBAAC,iBAAoBA,KAAI,CAAA;AAAA,IAAA,EAAA,CAAI,IAEzB;AAAAF,WAAAE;AAAAF,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAVDG,SAAAA;AAUC;AAGV,MAAMG,uBAAuDP,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AACvDQ,MAAAA,CAAAA,aAAaL,IAAI,GAAC;AAAA,WAAA;AAAA,EAAA;AAAAC,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAGJC,SAAAD,KAAIM,cAAe;AAACR,WAAAE;AAAAF,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAAvC,QAAAS,aAAmBN;AAAqBO,MAAAA;AAAAV,MAAAA,SAAAS,WAAAE,UAAAX,SAAAE,MAAA;AACjCQ,SAAAD,WAAUE,SAAA,IACf,oBAAC,iBAAsB,EAAA,OAAA,cACpBT,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AAA,6BACE,UAAC,oBAAA,UAAA,EAAeA,2BAAoB,CAAA,KAD5BA,qBAAoBjC,IAE9B;AAAM;AAMiC,SAAAG,OAAA+B,SAAA;AAAA,SAgClC,oBAAA,OAAA,EAA8BrC,OAAAA,QAAAA,GAAnBA,QAAKG,IAAuB;AAAA;AAhCL,SAAAK,OAAA8B,SAAA;AAAA,SAwChC,oBAAA,OAAA,EAA8BtC,OAAAA,QAAAA,GAAnBA,QAAKG,IAAuB;AAAA;AAaJ,SAAAU,OAAAE,KAAA;AAAA,SAEFA,CAAAA,IAAGX;AAAA;AAuCA,SAAAuB,OAAAY,SAAA;AAAA,SAyBtC,oBAAA,WAAA,EAAkCd,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AAzBL,SAAAyB,OAAAY,SAAA;AAAA,SAiCpC,oBAAA,WAAA,EAAkCf,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AA+BJ,SAAAgC,OAAAM,cAAA;AAU9C,SAAA,6BACE,UAAC,oBAAA,UAAA,EAAeA,mBAAY,CAAA,KADpBA,aAAYtC,IAEtB;AAAM;"}
|
package/dist/context.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
|
|
4
4
|
import { createContext, useRef, useEffect, useContext } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { useSchemaStore } from "@graphiql/react";
|
|
6
6
|
import { createStore, useStore } from "zustand";
|
|
7
7
|
function createDocExplorerStore(initialNavStackItem = {
|
|
8
8
|
name: "Docs"
|
|
@@ -147,55 +147,45 @@ function createDocExplorerStore(initialNavStackItem = {
|
|
|
147
147
|
}
|
|
148
148
|
const DocExplorerContext = createContext(null);
|
|
149
149
|
const DocExplorerContextProvider = (props) => {
|
|
150
|
-
const $ = c(
|
|
151
|
-
let t0;
|
|
152
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
153
|
-
t0 = {
|
|
154
|
-
nonNull: true,
|
|
155
|
-
caller: DocExplorerContextProvider
|
|
156
|
-
};
|
|
157
|
-
$[0] = t0;
|
|
158
|
-
} else {
|
|
159
|
-
t0 = $[0];
|
|
160
|
-
}
|
|
150
|
+
const $ = c(10);
|
|
161
151
|
const {
|
|
162
152
|
schema,
|
|
163
153
|
validationErrors,
|
|
164
154
|
schemaReference
|
|
165
|
-
} =
|
|
155
|
+
} = useSchemaStore();
|
|
166
156
|
const storeRef = useRef(null);
|
|
167
157
|
if (storeRef.current === null) {
|
|
168
|
-
let
|
|
169
|
-
if ($[
|
|
170
|
-
|
|
171
|
-
$[
|
|
158
|
+
let t02;
|
|
159
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
160
|
+
t02 = createDocExplorerStore();
|
|
161
|
+
$[0] = t02;
|
|
172
162
|
} else {
|
|
173
|
-
|
|
163
|
+
t02 = $[0];
|
|
174
164
|
}
|
|
175
|
-
storeRef.current =
|
|
165
|
+
storeRef.current = t02;
|
|
176
166
|
}
|
|
167
|
+
let t0;
|
|
177
168
|
let t1;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
t1 = () => {
|
|
169
|
+
if ($[1] !== schemaReference) {
|
|
170
|
+
t0 = () => {
|
|
181
171
|
const {
|
|
182
172
|
resolveSchemaReferenceToNavItem
|
|
183
173
|
} = storeRef.current.getState().actions;
|
|
184
174
|
resolveSchemaReferenceToNavItem(schemaReference);
|
|
185
175
|
};
|
|
186
|
-
|
|
187
|
-
$[
|
|
176
|
+
t1 = [schemaReference];
|
|
177
|
+
$[1] = schemaReference;
|
|
178
|
+
$[2] = t0;
|
|
188
179
|
$[3] = t1;
|
|
189
|
-
$[4] = t2;
|
|
190
180
|
} else {
|
|
181
|
+
t0 = $[2];
|
|
191
182
|
t1 = $[3];
|
|
192
|
-
t2 = $[4];
|
|
193
183
|
}
|
|
194
|
-
useEffect(
|
|
184
|
+
useEffect(t0, t1);
|
|
185
|
+
let t2;
|
|
195
186
|
let t3;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
t3 = () => {
|
|
187
|
+
if ($[4] !== schema || $[5] !== validationErrors) {
|
|
188
|
+
t2 = () => {
|
|
199
189
|
const {
|
|
200
190
|
reset,
|
|
201
191
|
rebuildNavStackWithSchema
|
|
@@ -206,25 +196,25 @@ const DocExplorerContextProvider = (props) => {
|
|
|
206
196
|
rebuildNavStackWithSchema(schema);
|
|
207
197
|
}
|
|
208
198
|
};
|
|
209
|
-
|
|
210
|
-
$[
|
|
211
|
-
$[
|
|
199
|
+
t3 = [schema, validationErrors];
|
|
200
|
+
$[4] = schema;
|
|
201
|
+
$[5] = validationErrors;
|
|
202
|
+
$[6] = t2;
|
|
212
203
|
$[7] = t3;
|
|
213
|
-
$[8] = t4;
|
|
214
204
|
} else {
|
|
205
|
+
t2 = $[6];
|
|
215
206
|
t3 = $[7];
|
|
216
|
-
t4 = $[8];
|
|
217
207
|
}
|
|
218
|
-
useEffect(
|
|
219
|
-
let
|
|
220
|
-
if ($[
|
|
221
|
-
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
208
|
+
useEffect(t2, t3);
|
|
209
|
+
let t4;
|
|
210
|
+
if ($[8] !== props.children) {
|
|
211
|
+
t4 = /* @__PURE__ */ jsx(DocExplorerContext.Provider, { value: storeRef, children: props.children });
|
|
212
|
+
$[8] = props.children;
|
|
213
|
+
$[9] = t4;
|
|
224
214
|
} else {
|
|
225
|
-
|
|
215
|
+
t4 = $[9];
|
|
226
216
|
}
|
|
227
|
-
return
|
|
217
|
+
return t4;
|
|
228
218
|
};
|
|
229
219
|
function useDocExplorerStore(selector) {
|
|
230
220
|
const store = useContext(DocExplorerContext);
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport {\n createContext,\n FC,\n ReactNode,\n RefObject,\n useContext,\n useEffect,\n useRef,\n} from 'react';\nimport { SchemaContextType, useSchemaContext } from '@graphiql/react';\nimport { createStore, StoreApi, useStore } from 'zustand';\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerContextType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: DocExplorerNavStack;\n actions: {\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: DocExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n resolveSchemaReferenceToNavItem(\n schemaReference: SchemaContextType['schemaReference'],\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nexport function createDocExplorerStore(\n initialNavStackItem: DocExplorerNavStackItem = { name: 'Docs' },\n) {\n return createStore<DocExplorerContextType>((set, get) => ({\n explorerNavStack: [initialNavStackItem],\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack: DocExplorerNavStack =\n curr.length === 1 ? curr : [initialNavStackItem];\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { push } = get().actions;\n switch (schemaReference.kind) {\n case 'Type': {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n break;\n }\n case 'Field': {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n break;\n }\n case 'Argument': {\n if (schemaReference.field) {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (schemaReference.type) {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n }\n break;\n }\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return oldNavStack;\n }\n const newNavStack: DocExplorerNavStack = [initialNavStackItem];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === initialNavStackItem) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return { explorerNavStack: newNavStack };\n });\n },\n },\n }));\n}\n\nexport const DocExplorerContext = createContext<RefObject<\n StoreApi<DocExplorerContextType>\n> | null>(null);\n\nexport const DocExplorerContextProvider: FC<{\n children: ReactNode;\n}> = props => {\n const { schema, validationErrors, schemaReference } = useSchemaContext({\n nonNull: true,\n caller: DocExplorerContextProvider,\n });\n\n const storeRef = useRef<StoreApi<DocExplorerContextType>>(null!);\n\n if (storeRef.current === null) {\n storeRef.current = createDocExplorerStore();\n }\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n storeRef.current.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n storeRef.current.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n return (\n <DocExplorerContext.Provider value={storeRef}>\n {props.children}\n </DocExplorerContext.Provider>\n );\n};\n\nfunction useDocExplorerStore<T>(\n selector: (state: DocExplorerContextType) => T,\n): T {\n const store = useContext(DocExplorerContext);\n if (!store) {\n throw new Error('Missing `DocExplorerContextProvider` in the tree');\n }\n return useStore(store.current, selector);\n}\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"names":["createDocExplorerStore","initialNavStackItem","name","createStore","set","get","explorerNavStack","actions","push","item","state","curr","lastItem","at","def","pop","length","slice","reset","resolveSchemaReferenceToNavItem","schemaReference","kind","type","field","rebuildNavStackWithSchema","schema","oldNavStack","newNavStack","lastEntity","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","args","some","a","DocExplorerContext","createContext","DocExplorerContextProvider","props","$","_c","t0","Symbol","for","nonNull","caller","validationErrors","useSchemaContext","storeRef","useRef","current","t1","t2","getState","useEffect","t3","t4","t5","children","useDocExplorerStore","selector","store","useContext","Error","useStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"mappings":";;;;;;AAkFO,SAASA,uBACdC,sBAA+C;AAAA,EAAEC,MAAM;AAAO,GAC9D;AACOC,SAAAA,YAAoC,CAACC,KAAKC,SAAS;AAAA,IACxDC,kBAAkB,CAACL,mBAAmB;AAAA,IACtCM,SAAS;AAAA,MACPC,KAAKC,MAAM;AACTL,YAAIM,CAAS,UAAA;AACX,gBAAMC,OAAOD,MAAMJ;AACbM,gBAAAA,WAAWD,KAAKE,GAAG,EAAE;AACrBP,gBAAAA;AAAAA;AAAAA,YAEJM,SAASE,QAAQL,KAAKK,MAAMH,OAAO,CAAC,GAAGA,MAAMF,IAAI;AAAA;AAE5C,iBAAA;AAAA,YAAEH;AAAAA,UAAiB;AAAA,QAAA,CAC3B;AAAA,MACH;AAAA,MACAS,MAAM;AACJX,YAAIM,CAAS,UAAA;AACX,gBAAMC,OAAOD,MAAMJ;AAEbA,gBAAAA,mBACJK,KAAKK,SAAS,IAAKL,KAAK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E,OAAAjE,OAAA;AAAA,SACNA,MAAKH;AAAA;"}
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport {\n createContext,\n FC,\n ReactNode,\n RefObject,\n useContext,\n useEffect,\n useRef,\n} from 'react';\nimport { SchemaContextType, useSchemaStore } from '@graphiql/react';\nimport { createStore, StoreApi, useStore } from 'zustand';\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerContextType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: DocExplorerNavStack;\n actions: {\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: DocExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n resolveSchemaReferenceToNavItem(\n schemaReference: SchemaContextType['schemaReference'],\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nexport function createDocExplorerStore(\n initialNavStackItem: DocExplorerNavStackItem = { name: 'Docs' },\n) {\n return createStore<DocExplorerContextType>((set, get) => ({\n explorerNavStack: [initialNavStackItem],\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack: DocExplorerNavStack =\n curr.length === 1 ? curr : [initialNavStackItem];\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { push } = get().actions;\n switch (schemaReference.kind) {\n case 'Type': {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n break;\n }\n case 'Field': {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n break;\n }\n case 'Argument': {\n if (schemaReference.field) {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (schemaReference.type) {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n }\n break;\n }\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return oldNavStack;\n }\n const newNavStack: DocExplorerNavStack = [initialNavStackItem];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === initialNavStackItem) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return { explorerNavStack: newNavStack };\n });\n },\n },\n }));\n}\n\nexport const DocExplorerContext = createContext<RefObject<\n StoreApi<DocExplorerContextType>\n> | null>(null);\n\nexport const DocExplorerContextProvider: FC<{\n children: ReactNode;\n}> = props => {\n const { schema, validationErrors, schemaReference } = useSchemaStore();\n const storeRef = useRef<StoreApi<DocExplorerContextType>>(null!);\n\n if (storeRef.current === null) {\n storeRef.current = createDocExplorerStore();\n }\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n storeRef.current.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n storeRef.current.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n return (\n <DocExplorerContext.Provider value={storeRef}>\n {props.children}\n </DocExplorerContext.Provider>\n );\n};\n\nfunction useDocExplorerStore<T>(\n selector: (state: DocExplorerContextType) => T,\n): T {\n const store = useContext(DocExplorerContext);\n if (!store) {\n throw new Error('Missing `DocExplorerContextProvider` in the tree');\n }\n return useStore(store.current, selector);\n}\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"names":["createDocExplorerStore","initialNavStackItem","name","createStore","set","get","explorerNavStack","actions","push","item","state","curr","lastItem","at","def","pop","length","slice","reset","resolveSchemaReferenceToNavItem","schemaReference","kind","type","field","rebuildNavStackWithSchema","schema","oldNavStack","newNavStack","lastEntity","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","args","some","a","DocExplorerContext","createContext","DocExplorerContextProvider","props","$","_c","validationErrors","useSchemaStore","storeRef","useRef","current","t0","Symbol","for","t1","getState","useEffect","t2","t3","t4","children","useDocExplorerStore","selector","store","useContext","Error","useStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"mappings":";;;;;;AAkFO,SAASA,uBACdC,sBAA+C;AAAA,EAAEC,MAAM;AAAO,GAC9D;AACOC,SAAAA,YAAoC,CAACC,KAAKC,SAAS;AAAA,IACxDC,kBAAkB,CAACL,mBAAmB;AAAA,IACtCM,SAAS;AAAA,MACPC,KAAKC,MAAM;AACTL,YAAIM,CAAS,UAAA;AACX,gBAAMC,OAAOD,MAAMJ;AACbM,gBAAAA,WAAWD,KAAKE,GAAG,EAAE;AACrBP,gBAAAA;AAAAA;AAAAA,YAEJM,SAASE,QAAQL,KAAKK,MAAMH,OAAO,CAAC,GAAGA,MAAMF,IAAI;AAAA;AAE5C,iBAAA;AAAA,YAAEH;AAAAA,UAAiB;AAAA,QAAA,CAC3B;AAAA,MACH;AAAA,MACAS,MAAM;AACJX,YAAIM,CAAS,UAAA;AACX,gBAAMC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.1-canary-9a1c125e.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"react-compiler-runtime": "19.1.0-rc.1",
|
|
45
|
-
"@graphiql/react": "^0.
|
|
45
|
+
"@graphiql/react": "^0.33.0-canary-9a1c125e.0",
|
|
46
46
|
"@headlessui/react": "^2.2",
|
|
47
47
|
"zustand": "^5"
|
|
48
48
|
},
|