@graphiql/plugin-doc-explorer 0.3.0-rc.0 → 0.4.0-canary-75298f4c.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 +121 -114
- package/dist/components/doc-explorer.js.map +1 -1
- package/dist/components/schema-documentation.js +44 -29
- package/dist/components/schema-documentation.js.map +1 -1
- package/dist/components/search.js +37 -32
- package/dist/components/search.js.map +1 -1
- package/dist/components/type-documentation.js +6 -6
- package/dist/components/type-documentation.js.map +1 -1
- package/dist/components/type-link.js +4 -7
- package/dist/components/type-link.js.map +1 -1
- package/dist/context.js +27 -20
- package/dist/context.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.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 { pick, useGraphiQL, 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,98 +9,105 @@ import { Search } from "./search.js";
|
|
|
9
9
|
import { TypeDocumentation } from "./type-documentation.js";
|
|
10
10
|
/* empty css */
|
|
11
11
|
const DocExplorer = () => {
|
|
12
|
-
const $ = c(
|
|
12
|
+
const $ = c(39);
|
|
13
|
+
let t0;
|
|
14
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
15
|
+
t0 = pick("fetchError", "isFetching", "schema", "validationErrors");
|
|
16
|
+
$[0] = t0;
|
|
17
|
+
} else {
|
|
18
|
+
t0 = $[0];
|
|
19
|
+
}
|
|
13
20
|
const {
|
|
14
21
|
fetchError,
|
|
15
22
|
isFetching,
|
|
16
23
|
schema,
|
|
17
24
|
validationErrors
|
|
18
|
-
} =
|
|
25
|
+
} = useGraphiQL(t0);
|
|
19
26
|
const explorerNavStack = useDocExplorer();
|
|
20
27
|
const {
|
|
21
28
|
pop
|
|
22
29
|
} = useDocExplorerActions();
|
|
23
30
|
let content;
|
|
24
31
|
let navItem;
|
|
25
|
-
if ($[
|
|
32
|
+
if ($[1] !== explorerNavStack || $[2] !== fetchError || $[3] !== isFetching || $[4] !== schema || $[5] !== validationErrors) {
|
|
26
33
|
navItem = explorerNavStack.at(-1);
|
|
27
34
|
content = null;
|
|
28
35
|
if (fetchError) {
|
|
29
|
-
let
|
|
30
|
-
if ($[
|
|
31
|
-
|
|
32
|
-
$[
|
|
36
|
+
let t12;
|
|
37
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
38
|
+
t12 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "Error fetching schema" });
|
|
39
|
+
$[8] = t12;
|
|
33
40
|
} else {
|
|
34
|
-
|
|
41
|
+
t12 = $[8];
|
|
35
42
|
}
|
|
36
|
-
content =
|
|
43
|
+
content = t12;
|
|
37
44
|
} else {
|
|
38
|
-
if (validationErrors
|
|
39
|
-
let
|
|
40
|
-
if ($[
|
|
41
|
-
|
|
45
|
+
if (validationErrors[0]) {
|
|
46
|
+
let t12;
|
|
47
|
+
if ($[9] !== validationErrors[0].message) {
|
|
48
|
+
t12 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-error", children: [
|
|
42
49
|
"Schema is invalid: ",
|
|
43
50
|
validationErrors[0].message
|
|
44
51
|
] });
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
52
|
+
$[9] = validationErrors[0].message;
|
|
53
|
+
$[10] = t12;
|
|
47
54
|
} else {
|
|
48
|
-
|
|
55
|
+
t12 = $[10];
|
|
49
56
|
}
|
|
50
|
-
content =
|
|
57
|
+
content = t12;
|
|
51
58
|
} else {
|
|
52
59
|
if (isFetching) {
|
|
53
|
-
let
|
|
54
|
-
if ($[
|
|
55
|
-
|
|
56
|
-
$[
|
|
60
|
+
let t12;
|
|
61
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
62
|
+
t12 = /* @__PURE__ */ jsx(Spinner, {});
|
|
63
|
+
$[11] = t12;
|
|
57
64
|
} else {
|
|
58
|
-
|
|
65
|
+
t12 = $[11];
|
|
59
66
|
}
|
|
60
|
-
content =
|
|
67
|
+
content = t12;
|
|
61
68
|
} else {
|
|
62
69
|
if (!schema) {
|
|
63
|
-
let
|
|
64
|
-
if ($[
|
|
65
|
-
|
|
66
|
-
$[
|
|
70
|
+
let t12;
|
|
71
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
72
|
+
t12 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "No GraphQL schema available" });
|
|
73
|
+
$[12] = t12;
|
|
67
74
|
} else {
|
|
68
|
-
|
|
75
|
+
t12 = $[12];
|
|
69
76
|
}
|
|
70
|
-
content =
|
|
77
|
+
content = t12;
|
|
71
78
|
} else {
|
|
72
79
|
if (explorerNavStack.length === 1) {
|
|
73
|
-
let
|
|
74
|
-
if ($[
|
|
75
|
-
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
80
|
+
let t12;
|
|
81
|
+
if ($[13] !== schema) {
|
|
82
|
+
t12 = /* @__PURE__ */ jsx(SchemaDocumentation, { schema });
|
|
83
|
+
$[13] = schema;
|
|
84
|
+
$[14] = t12;
|
|
78
85
|
} else {
|
|
79
|
-
|
|
86
|
+
t12 = $[14];
|
|
80
87
|
}
|
|
81
|
-
content =
|
|
88
|
+
content = t12;
|
|
82
89
|
} else {
|
|
83
90
|
if (isType(navItem.def)) {
|
|
84
|
-
let
|
|
85
|
-
if ($[
|
|
86
|
-
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
91
|
+
let t12;
|
|
92
|
+
if ($[15] !== navItem.def) {
|
|
93
|
+
t12 = /* @__PURE__ */ jsx(TypeDocumentation, { type: navItem.def });
|
|
94
|
+
$[15] = navItem.def;
|
|
95
|
+
$[16] = t12;
|
|
89
96
|
} else {
|
|
90
|
-
|
|
97
|
+
t12 = $[16];
|
|
91
98
|
}
|
|
92
|
-
content =
|
|
99
|
+
content = t12;
|
|
93
100
|
} else {
|
|
94
101
|
if (navItem.def) {
|
|
95
|
-
let
|
|
96
|
-
if ($[
|
|
97
|
-
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
102
|
+
let t12;
|
|
103
|
+
if ($[17] !== navItem.def) {
|
|
104
|
+
t12 = /* @__PURE__ */ jsx(FieldDocumentation, { field: navItem.def });
|
|
105
|
+
$[17] = navItem.def;
|
|
106
|
+
$[18] = t12;
|
|
100
107
|
} else {
|
|
101
|
-
|
|
108
|
+
t12 = $[18];
|
|
102
109
|
}
|
|
103
|
-
content =
|
|
110
|
+
content = t12;
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -108,105 +115,105 @@ const DocExplorer = () => {
|
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
+
$[1] = explorerNavStack;
|
|
119
|
+
$[2] = fetchError;
|
|
120
|
+
$[3] = isFetching;
|
|
121
|
+
$[4] = schema;
|
|
122
|
+
$[5] = validationErrors;
|
|
123
|
+
$[6] = content;
|
|
124
|
+
$[7] = navItem;
|
|
118
125
|
} else {
|
|
119
|
-
content = $[
|
|
120
|
-
navItem = $[
|
|
126
|
+
content = $[6];
|
|
127
|
+
navItem = $[7];
|
|
121
128
|
}
|
|
122
129
|
let prevName;
|
|
123
130
|
if (explorerNavStack.length > 1) {
|
|
124
|
-
let
|
|
125
|
-
if ($[
|
|
126
|
-
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
131
|
+
let t12;
|
|
132
|
+
if ($[19] !== explorerNavStack) {
|
|
133
|
+
t12 = explorerNavStack.at(-2);
|
|
134
|
+
$[19] = explorerNavStack;
|
|
135
|
+
$[20] = t12;
|
|
129
136
|
} else {
|
|
130
|
-
|
|
137
|
+
t12 = $[20];
|
|
131
138
|
}
|
|
132
|
-
prevName =
|
|
139
|
+
prevName = t12.name;
|
|
133
140
|
}
|
|
134
|
-
let
|
|
135
|
-
if ($[
|
|
136
|
-
|
|
141
|
+
let t1;
|
|
142
|
+
if ($[21] !== pop || $[22] !== prevName) {
|
|
143
|
+
t1 = prevName && /* @__PURE__ */ jsxs("a", { href: "#", className: "graphiql-doc-explorer-back", onClick: (event) => {
|
|
137
144
|
event.preventDefault();
|
|
138
145
|
pop();
|
|
139
146
|
}, "aria-label": `Go back to ${prevName}`, children: [
|
|
140
147
|
/* @__PURE__ */ jsx(ChevronLeftIcon, {}),
|
|
141
148
|
prevName
|
|
142
149
|
] });
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
150
|
+
$[21] = pop;
|
|
151
|
+
$[22] = prevName;
|
|
152
|
+
$[23] = t1;
|
|
146
153
|
} else {
|
|
147
|
-
|
|
154
|
+
t1 = $[23];
|
|
148
155
|
}
|
|
149
|
-
let
|
|
150
|
-
if ($[
|
|
151
|
-
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
156
|
+
let t2;
|
|
157
|
+
if ($[24] !== navItem.name) {
|
|
158
|
+
t2 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-title", children: navItem.name });
|
|
159
|
+
$[24] = navItem.name;
|
|
160
|
+
$[25] = t2;
|
|
154
161
|
} else {
|
|
155
|
-
|
|
162
|
+
t2 = $[25];
|
|
156
163
|
}
|
|
157
|
-
let
|
|
158
|
-
if ($[
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
let t3;
|
|
165
|
+
if ($[26] !== t1 || $[27] !== t2) {
|
|
166
|
+
t3 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header-content", children: [
|
|
167
|
+
t1,
|
|
168
|
+
t2
|
|
162
169
|
] });
|
|
163
|
-
$[25] = t0;
|
|
164
170
|
$[26] = t1;
|
|
165
171
|
$[27] = t2;
|
|
172
|
+
$[28] = t3;
|
|
166
173
|
} else {
|
|
167
|
-
|
|
174
|
+
t3 = $[28];
|
|
168
175
|
}
|
|
169
|
-
let
|
|
170
|
-
if ($[
|
|
171
|
-
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
176
|
+
let t4;
|
|
177
|
+
if ($[29] !== navItem.name) {
|
|
178
|
+
t4 = /* @__PURE__ */ jsx(Search, {}, navItem.name);
|
|
179
|
+
$[29] = navItem.name;
|
|
180
|
+
$[30] = t4;
|
|
174
181
|
} else {
|
|
175
|
-
|
|
182
|
+
t4 = $[30];
|
|
176
183
|
}
|
|
177
|
-
let
|
|
178
|
-
if ($[
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
let t5;
|
|
185
|
+
if ($[31] !== t3 || $[32] !== t4) {
|
|
186
|
+
t5 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header", children: [
|
|
187
|
+
t3,
|
|
188
|
+
t4
|
|
182
189
|
] });
|
|
183
|
-
$[30] = t2;
|
|
184
190
|
$[31] = t3;
|
|
185
191
|
$[32] = t4;
|
|
192
|
+
$[33] = t5;
|
|
186
193
|
} else {
|
|
187
|
-
|
|
194
|
+
t5 = $[33];
|
|
188
195
|
}
|
|
189
|
-
let
|
|
190
|
-
if ($[
|
|
191
|
-
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
196
|
+
let t6;
|
|
197
|
+
if ($[34] !== content) {
|
|
198
|
+
t6 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-content", children: content });
|
|
199
|
+
$[34] = content;
|
|
200
|
+
$[35] = t6;
|
|
194
201
|
} else {
|
|
195
|
-
|
|
202
|
+
t6 = $[35];
|
|
196
203
|
}
|
|
197
|
-
let
|
|
198
|
-
if ($[
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
let t7;
|
|
205
|
+
if ($[36] !== t5 || $[37] !== t6) {
|
|
206
|
+
t7 = /* @__PURE__ */ jsxs("section", { className: "graphiql-doc-explorer", "aria-label": "Documentation Explorer", children: [
|
|
207
|
+
t5,
|
|
208
|
+
t6
|
|
202
209
|
] });
|
|
203
|
-
$[35] = t4;
|
|
204
210
|
$[36] = t5;
|
|
205
211
|
$[37] = t6;
|
|
212
|
+
$[38] = t7;
|
|
206
213
|
} else {
|
|
207
|
-
|
|
214
|
+
t7 = $[38];
|
|
208
215
|
}
|
|
209
|
-
return
|
|
216
|
+
return t7;
|
|
210
217
|
};
|
|
211
218
|
export {
|
|
212
219
|
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, useGraphiQL, pick } 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 } = useGraphiQL(\n pick('fetchError', 'isFetching', 'schema', 'validationErrors'),\n );\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[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","t0","Symbol","for","pick","fetchError","isFetching","schema","validationErrors","useGraphiQL","explorerNavStack","useDocExplorer","pop","useDocExplorerActions","content","navItem","at","t1","message","length","isType","def","prevName","event","preventDefault","t2","name","t3","t4","t5","t6","t7"],"mappings":";;;;;;;;;;AAUO,MAAMA,cAAkBA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAE3BF,SAAAG,KAAK,cAAc,cAAc,UAAU,kBAAkB;AAACL,WAAAE;AAAAA,EAAAA,OAAA;AAAA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AAAA,EAAA;AAzBVgC,SAAAA;AAyBU;"}
|
|
@@ -5,8 +5,7 @@ import { ExplorerSection } from "./section.js";
|
|
|
5
5
|
import { TypeLink } from "./type-link.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
const SchemaDocumentation = (t0) => {
|
|
8
|
-
|
|
9
|
-
const $ = c(39);
|
|
8
|
+
const $ = c(43);
|
|
10
9
|
const {
|
|
11
10
|
schema
|
|
12
11
|
} = t0;
|
|
@@ -21,7 +20,7 @@ const SchemaDocumentation = (t0) => {
|
|
|
21
20
|
const queryType = t1;
|
|
22
21
|
let t2;
|
|
23
22
|
if ($[2] !== schema) {
|
|
24
|
-
t2 =
|
|
23
|
+
t2 = schema.getMutationType();
|
|
25
24
|
$[2] = schema;
|
|
26
25
|
$[3] = t2;
|
|
27
26
|
} else {
|
|
@@ -30,7 +29,7 @@ const SchemaDocumentation = (t0) => {
|
|
|
30
29
|
const mutationType = t2;
|
|
31
30
|
let t3;
|
|
32
31
|
if ($[4] !== schema) {
|
|
33
|
-
t3 =
|
|
32
|
+
t3 = schema.getSubscriptionType();
|
|
34
33
|
$[4] = schema;
|
|
35
34
|
$[5] = t3;
|
|
36
35
|
} else {
|
|
@@ -46,11 +45,11 @@ const SchemaDocumentation = (t0) => {
|
|
|
46
45
|
const typeMap = schema.getTypeMap();
|
|
47
46
|
const t82 = queryType == null ? void 0 : queryType.name;
|
|
48
47
|
const t92 = mutationType == null ? void 0 : mutationType.name;
|
|
49
|
-
const
|
|
48
|
+
const t102 = subscriptionType == null ? void 0 : subscriptionType.name;
|
|
50
49
|
let t11;
|
|
51
|
-
if ($[15] !==
|
|
52
|
-
t11 = [t82, t92,
|
|
53
|
-
$[15] =
|
|
50
|
+
if ($[15] !== t102 || $[16] !== t82 || $[17] !== t92) {
|
|
51
|
+
t11 = [t82, t92, t102];
|
|
52
|
+
$[15] = t102;
|
|
54
53
|
$[16] = t82;
|
|
55
54
|
$[17] = t92;
|
|
56
55
|
$[18] = t11;
|
|
@@ -116,13 +115,21 @@ const SchemaDocumentation = (t0) => {
|
|
|
116
115
|
t7 = $[30];
|
|
117
116
|
}
|
|
118
117
|
T0 = ExplorerSection;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
t5 = "All Schema Types";
|
|
119
|
+
let t16;
|
|
120
|
+
if ($[31] !== ignoreTypesInAllSchema) {
|
|
121
|
+
t16 = (type) => {
|
|
122
|
+
if (ignoreTypesInAllSchema.includes(type.name) || type.name.startsWith("__")) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TypeLink, { type }) }, type.name);
|
|
126
|
+
};
|
|
127
|
+
$[31] = ignoreTypesInAllSchema;
|
|
128
|
+
$[32] = t16;
|
|
129
|
+
} else {
|
|
130
|
+
t16 = $[32];
|
|
131
|
+
}
|
|
132
|
+
t4 = Object.values(typeMap).map(t16);
|
|
126
133
|
$[6] = mutationType;
|
|
127
134
|
$[7] = queryType;
|
|
128
135
|
$[8] = schema;
|
|
@@ -140,30 +147,38 @@ const SchemaDocumentation = (t0) => {
|
|
|
140
147
|
t7 = $[14];
|
|
141
148
|
}
|
|
142
149
|
let t8;
|
|
143
|
-
if ($[
|
|
144
|
-
t8 = /* @__PURE__ */ jsx(
|
|
145
|
-
$[
|
|
146
|
-
$[32] = t4;
|
|
147
|
-
$[33] = t5;
|
|
150
|
+
if ($[33] !== t4) {
|
|
151
|
+
t8 = /* @__PURE__ */ jsx("div", { children: t4 });
|
|
152
|
+
$[33] = t4;
|
|
148
153
|
$[34] = t8;
|
|
149
154
|
} else {
|
|
150
155
|
t8 = $[34];
|
|
151
156
|
}
|
|
152
157
|
let t9;
|
|
153
|
-
if ($[35] !==
|
|
154
|
-
t9 = /* @__PURE__ */
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
t8
|
|
158
|
-
] });
|
|
159
|
-
$[35] = t6;
|
|
160
|
-
$[36] = t7;
|
|
158
|
+
if ($[35] !== T0 || $[36] !== t5 || $[37] !== t8) {
|
|
159
|
+
t9 = /* @__PURE__ */ jsx(T0, { title: t5, children: t8 });
|
|
160
|
+
$[35] = T0;
|
|
161
|
+
$[36] = t5;
|
|
161
162
|
$[37] = t8;
|
|
162
163
|
$[38] = t9;
|
|
163
164
|
} else {
|
|
164
165
|
t9 = $[38];
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
+
let t10;
|
|
168
|
+
if ($[39] !== t6 || $[40] !== t7 || $[41] !== t9) {
|
|
169
|
+
t10 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
170
|
+
t6,
|
|
171
|
+
t7,
|
|
172
|
+
t9
|
|
173
|
+
] });
|
|
174
|
+
$[39] = t6;
|
|
175
|
+
$[40] = t7;
|
|
176
|
+
$[41] = t9;
|
|
177
|
+
$[42] = t10;
|
|
178
|
+
} else {
|
|
179
|
+
t10 = $[42];
|
|
180
|
+
}
|
|
181
|
+
return t10;
|
|
167
182
|
};
|
|
168
183
|
export {
|
|
169
184
|
SchemaDocumentation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-documentation.js","sources":["../../src/components/schema-documentation.tsx"],"sourcesContent":["import { FC } from 'react';\nimport type { GraphQLSchema } from 'graphql';\nimport { MarkdownContent } from '@graphiql/react';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './schema-documentation.css';\n\ntype SchemaDocumentationProps = {\n /**\n * The schema that should be rendered.\n */\n schema: GraphQLSchema;\n};\n\nexport const SchemaDocumentation: FC<SchemaDocumentationProps> = ({\n schema,\n}) => {\n const queryType = schema.getQueryType();\n const mutationType = schema.getMutationType
|
|
1
|
+
{"version":3,"file":"schema-documentation.js","sources":["../../src/components/schema-documentation.tsx"],"sourcesContent":["import { FC } from 'react';\nimport type { GraphQLSchema } from 'graphql';\nimport { MarkdownContent } from '@graphiql/react';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './schema-documentation.css';\n\ntype SchemaDocumentationProps = {\n /**\n * The schema that should be rendered.\n */\n schema: GraphQLSchema;\n};\n\nexport const SchemaDocumentation: FC<SchemaDocumentationProps> = ({\n schema,\n}) => {\n const queryType = schema.getQueryType();\n const mutationType = schema.getMutationType();\n const subscriptionType = schema.getSubscriptionType();\n const typeMap = schema.getTypeMap();\n const ignoreTypesInAllSchema = [\n queryType?.name,\n mutationType?.name,\n subscriptionType?.name,\n ];\n\n return (\n <>\n <MarkdownContent type=\"description\">\n {schema.description ||\n 'A GraphQL schema provides a root type for each kind of operation.'}\n </MarkdownContent>\n <ExplorerSection title=\"Root Types\">\n {queryType ? (\n <div>\n <span className=\"graphiql-doc-explorer-root-type\">query</span>\n {': '}\n <TypeLink type={queryType} />\n </div>\n ) : null}\n {mutationType && (\n <div>\n <span className=\"graphiql-doc-explorer-root-type\">mutation</span>\n {': '}\n <TypeLink type={mutationType} />\n </div>\n )}\n {subscriptionType && (\n <div>\n <span className=\"graphiql-doc-explorer-root-type\">\n subscription\n </span>\n {': '}\n <TypeLink type={subscriptionType} />\n </div>\n )}\n </ExplorerSection>\n <ExplorerSection title=\"All Schema Types\">\n <div>\n {Object.values(typeMap).map(type => {\n if (\n ignoreTypesInAllSchema.includes(type.name) ||\n type.name.startsWith('__')\n ) {\n return null;\n }\n\n return (\n <div key={type.name}>\n <TypeLink type={type} />\n </div>\n );\n })}\n </div>\n </ExplorerSection>\n </>\n );\n};\n"],"names":["SchemaDocumentation","t0","$","_c","schema","t1","getQueryType","queryType","t2","getMutationType","mutationType","t3","getSubscriptionType","subscriptionType","T0","t4","t5","t6","t7","typeMap","getTypeMap","t8","name","t9","t10","t11","ignoreTypesInAllSchema","t12","description","t13","t14","t15","ExplorerSection","t16","type","includes","startsWith","Object","values","map"],"mappings":";;;;;;AAcO,MAAMA,sBAAoDC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAC,QA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AAAd,EAAA,EAAA,MAAAmB,IAAA;AAhBRE,SAAC,oBAAA,IAAA,EAAsB,OAAAP,IACrBK,UAgBF,IAAA;AAAkBnB,YAAAY;AAAAZ,YAAAc;AAAAd,YAAAmB;AAAAnB,YAAAqB;AAAAA,EAAAA,OAAA;AAAAA,SAAArB,EAAA,EAAA;AAAA,EAAA;AAAAsB,MAAAA;AAAAtB,MAAAA,EAAAe,EAAAA,MAAAA,MAAAf,UAAAgB,MAAAhB,EAAA,EAAA,MAAAqB,IAAA;AA/CpBC,UACEP,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA;AAAAA,MAIAC;AAAAA,MAyBAK;AAAAA,IAAAA,GAiBkB;AACjBrB,YAAAe;AAAAf,YAAAgB;AAAAhB,YAAAqB;AAAArB,YAAAsB;AAAAA,EAAAA,OAAA;AAAAA,UAAAtB,EAAA,EAAA;AAAA,EAAA;AAhDHsB,SAAAA;AAgDG;"}
|
|
@@ -3,12 +3,12 @@ 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, formatShortcutForOS, KEY_MAP, useGraphiQL, MagnifyingGlassIcon } from "@graphiql/react";
|
|
7
7
|
import { useDocExplorer, useDocExplorerActions } from "../context.js";
|
|
8
8
|
import { renderType } from "./utils.js";
|
|
9
9
|
/* empty css */
|
|
10
10
|
const Search = () => {
|
|
11
|
-
const $ = c(
|
|
11
|
+
const $ = c(34);
|
|
12
12
|
const explorerNavStack = useDocExplorer();
|
|
13
13
|
const {
|
|
14
14
|
push
|
|
@@ -128,58 +128,63 @@ const Search = () => {
|
|
|
128
128
|
t9 = $[19];
|
|
129
129
|
}
|
|
130
130
|
let t11;
|
|
131
|
+
let t12;
|
|
131
132
|
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
132
133
|
t11 = (event_0) => setSearchValue(event_0.target.value);
|
|
134
|
+
t12 = formatShortcutForOS(KEY_MAP.searchInDocs.key.replace("-", " "));
|
|
133
135
|
$[20] = t11;
|
|
136
|
+
$[21] = t12;
|
|
134
137
|
} else {
|
|
135
138
|
t11 = $[20];
|
|
139
|
+
t12 = $[21];
|
|
136
140
|
}
|
|
137
|
-
let
|
|
138
|
-
if ($[
|
|
139
|
-
|
|
141
|
+
let t13;
|
|
142
|
+
if ($[22] !== searchValue || $[23] !== t12) {
|
|
143
|
+
t13 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-search-input", onClick: t9, children: [
|
|
140
144
|
t10,
|
|
141
|
-
/* @__PURE__ */ jsx(ComboboxInput, { autoComplete: "off", onChange: t11, placeholder:
|
|
145
|
+
/* @__PURE__ */ jsx(ComboboxInput, { autoComplete: "off", onChange: t11, placeholder: t12, ref: inputRef, value: searchValue, "data-cy": "doc-explorer-input" })
|
|
142
146
|
] });
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
147
|
+
$[22] = searchValue;
|
|
148
|
+
$[23] = t12;
|
|
149
|
+
$[24] = t13;
|
|
145
150
|
} else {
|
|
146
|
-
|
|
151
|
+
t13 = $[24];
|
|
147
152
|
}
|
|
148
|
-
let
|
|
149
|
-
if ($[
|
|
150
|
-
|
|
153
|
+
let t14;
|
|
154
|
+
if ($[25] !== isFocused || $[26] !== results) {
|
|
155
|
+
t14 = isFocused && /* @__PURE__ */ jsxs(ComboboxOptions, { "data-cy": "doc-explorer-list", children: [
|
|
151
156
|
results.within.length + results.types.length + results.fields.length === 0 ? /* @__PURE__ */ jsx("li", { className: "graphiql-doc-explorer-search-empty", children: "No results found" }) : results.within.map(_temp),
|
|
152
157
|
results.within.length > 0 && results.types.length + results.fields.length > 0 ? /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-search-divider", children: "Other results" }) : null,
|
|
153
158
|
results.types.map(_temp2),
|
|
154
159
|
results.fields.map(_temp3)
|
|
155
160
|
] });
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
161
|
+
$[25] = isFocused;
|
|
162
|
+
$[26] = results;
|
|
163
|
+
$[27] = t14;
|
|
159
164
|
} else {
|
|
160
|
-
|
|
165
|
+
t14 = $[27];
|
|
161
166
|
}
|
|
162
|
-
let
|
|
163
|
-
if ($[
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
let t15;
|
|
168
|
+
if ($[28] !== onSelect || $[29] !== t13 || $[30] !== t14 || $[31] !== t7 || $[32] !== t8) {
|
|
169
|
+
t15 = /* @__PURE__ */ jsxs(Combobox, { as: "div", className: "graphiql-doc-explorer-search", onChange: onSelect, "data-state": t7, "aria-label": t8, children: [
|
|
170
|
+
t13,
|
|
171
|
+
t14
|
|
167
172
|
] });
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
173
|
+
$[28] = onSelect;
|
|
174
|
+
$[29] = t13;
|
|
175
|
+
$[30] = t14;
|
|
176
|
+
$[31] = t7;
|
|
177
|
+
$[32] = t8;
|
|
178
|
+
$[33] = t15;
|
|
174
179
|
} else {
|
|
175
|
-
|
|
180
|
+
t15 = $[33];
|
|
176
181
|
}
|
|
177
|
-
return
|
|
182
|
+
return t15;
|
|
178
183
|
};
|
|
179
184
|
function useSearchResults() {
|
|
180
185
|
const $ = c(5);
|
|
181
186
|
const explorerNavStack = useDocExplorer();
|
|
182
|
-
const schema =
|
|
187
|
+
const schema = useGraphiQL(_temp4);
|
|
183
188
|
let t0;
|
|
184
189
|
if ($[0] !== explorerNavStack) {
|
|
185
190
|
t0 = explorerNavStack.at(-1);
|
|
@@ -254,8 +259,8 @@ function useSearchResults() {
|
|
|
254
259
|
}
|
|
255
260
|
return t1;
|
|
256
261
|
}
|
|
257
|
-
function _temp4(
|
|
258
|
-
return
|
|
262
|
+
function _temp4(state) {
|
|
263
|
+
return state.schema;
|
|
259
264
|
}
|
|
260
265
|
function isMatch(sourceText, searchValue) {
|
|
261
266
|
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 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(store => store.schema);\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","_temp4","matches","withinType","typeMap","getTypeMap","typeNames","Object","keys","filter","n","unshift","typeName","isMatch","getFields","fieldName","matchingArgs","args","arg","argument","store","sourceText","escaped","replaceAll","ch","RegExp","test","toLowerCase","includes","Type","Field","renderType","_temp5","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,WAA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,KAAA;AAAA,SA6Gb,qBAAA,gBAAA,EAEQL,iBACC,WAAA,uBAER,UAAA;AAAA,IAAC,oBAAA,MAAA,EAAW,MAAAA,SAAM3D,KAAS,CAAA;AAAA,IAAA;AAAA,wBAC1B,OAAa,EAAA,OAAA2D,SAAM5D,OAAkB,UAAA4D,SAAMd,SAAS,CAAA;AAAA,gBALvCe,GAAC,EAMjB;AAAiB;AAoHC,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 formatShortcutForOS,\n useGraphiQL,\n MagnifyingGlassIcon,\n debounce,\n KEY_MAP,\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={formatShortcutForOS(\n KEY_MAP.searchInDocs.key.replace('-', ' '),\n )}\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 = useGraphiQL(state => state.schema);\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","t12","event_0","target","value","formatShortcutForOS","KEY_MAP","searchInDocs","replace","t13","t14","within","types","fields","map","_temp","_temp2","_temp3","t15","schema","useGraphiQL","_temp4","matches","withinType","typeMap","getTypeMap","typeNames","Object","keys","filter","n","unshift","typeName","isMatch","getFields","fieldName","matchingArgs","args","arg","argument","state","sourceText","escaped","replaceAll","ch","RegExp","test","toLowerCase","includes","Type","Field","renderType","_temp5","result","i","result_0","i_0","result_1","i_1","namedType"],"mappings":";;;;;;;;;AA2BO,MAAMA,SAAaA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AACxB,QAAAC,mBAAyBC,eAAe;AACxC,QAAA;AAAA,IAAAC;AAA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AA3PmB,SAAA+C,MAAAsC,QAAAC,GAAA;AAAA,6BAsFX,gBAEQD,EAAAA,OAAK,QACJ,WAAA,uBAER,UAAC,oBAAA,OAAA,EAAa,OAAAA,OAAMhE,OAAkB,UAAAgE,OAAMd,UAC9C,EALO,GAAA,UAAUe,CAAC,EAKlB;AAAiB;AA5FL,SAAAtC,OAAAuC,UAAAC,KAAA;AAAA,SAsGb,oBAAA,gBAAA,EAEQH,OAAAA,UACC,WAAA,uBAER,UAAA,oBAAC,MAAW,EAAA,MAAAA,SAAM/D,KACpB,CAAA,EALegE,GAAAA,QAAAA,GAAC,EAKhB;AAAiB;AA5GH,SAAArC,OAAAwC,UAAAC,KAAA;AAAA,SA+Gb,qBAAA,gBAAA,EAEQL,iBACC,WAAA,uBAER,UAAA;AAAA,IAAC,oBAAA,MAAA,EAAW,MAAAA,SAAM/D,KAAS,CAAA;AAAA,IAAA;AAAA,wBAC1B,OAAa,EAAA,OAAA+D,SAAMhE,OAAkB,UAAAgE,SAAMd,SAAS,CAAA;AAAA,gBALvCe,GAAC,EAMjB;AAAiB;AAoHC,SAAAF,OAAAO,WAAA;AAYlB,SAAA,oBAAC,MAAWA,EAAAA,MAAAA,UAAa,CAAA;AAAA;"}
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
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, useGraphiQL } 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";
|
|
@@ -250,7 +250,7 @@ const EnumValues = (t0) => {
|
|
|
250
250
|
values.push(value);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
t2 = values.length > 0
|
|
253
|
+
t2 = values.length > 0 && /* @__PURE__ */ jsx(ExplorerSection, { title: "Enum Values", children: values.map(_temp5) });
|
|
254
254
|
$[1] = type;
|
|
255
255
|
$[2] = deprecatedValues;
|
|
256
256
|
$[3] = t2;
|
|
@@ -262,7 +262,7 @@ const EnumValues = (t0) => {
|
|
|
262
262
|
}
|
|
263
263
|
let t3;
|
|
264
264
|
if ($[5] !== deprecatedValues || $[6] !== showDeprecated || $[7] !== values.length) {
|
|
265
|
-
t3 = deprecatedValues.length > 0
|
|
265
|
+
t3 = deprecatedValues.length > 0 && (showDeprecated || !values.length ? /* @__PURE__ */ jsx(ExplorerSection, { title: "Deprecated Enum Values", children: deprecatedValues.map(_temp6) }) : /* @__PURE__ */ jsx(Button, { type: "button", onClick: handleShowDeprecated, children: "Show Deprecated Values" }));
|
|
266
266
|
$[5] = deprecatedValues;
|
|
267
267
|
$[6] = showDeprecated;
|
|
268
268
|
$[7] = values.length;
|
|
@@ -334,7 +334,7 @@ const PossibleTypes = (t0) => {
|
|
|
334
334
|
const {
|
|
335
335
|
type
|
|
336
336
|
} = t0;
|
|
337
|
-
const schema =
|
|
337
|
+
const schema = useGraphiQL(_temp7);
|
|
338
338
|
if (!schema || !isAbstractType(type)) {
|
|
339
339
|
return null;
|
|
340
340
|
}
|
|
@@ -377,8 +377,8 @@ function _temp5(value_0) {
|
|
|
377
377
|
function _temp6(value_1) {
|
|
378
378
|
return /* @__PURE__ */ jsx(EnumValue, { value: value_1 }, value_1.name);
|
|
379
379
|
}
|
|
380
|
-
function _temp7(
|
|
381
|
-
return
|
|
380
|
+
function _temp7(state) {
|
|
381
|
+
return state.schema;
|
|
382
382
|
}
|
|
383
383
|
function _temp8(possibleType) {
|
|
384
384
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TypeLink, { type: possibleType }) }, possibleType.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 { 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 )}\n {value.deprecationReason && (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n )}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const schema = useSchemaStore(store => store.schema);\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","_temp7","isAbstractType","getPossibleTypes","_temp8","implementedInterface","field_0","field_1","value_0","value_1","store","possibleType"],"mappings":";;;;;;;;;;;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KG,IAAuB;AAAA;AAhCL,SAAAK,OAAA+B,SAAA;AAAA,SAwChC,oBAAA,OAAA,EAA8BvC,OAAAA,QAAAA,GAAnBA,QAAKG,IAAuB;AAAA;AAaJ,SAAAU,OAAAE,KAAA;AAAA,SAEFA,CAAAA,IAAGX;AAAA;AAuCA,SAAAuB,OAAAa,SAAA;AAAA,SAyBtC,oBAAA,WAAA,EAAkCf,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AAzBL,SAAAyB,OAAAa,SAAA;AAAA,SAiCpC,oBAAA,WAAA,EAAkChB,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AA+BJ,SAAA8B,OAAAS,OAAA;AAAA,SACbA,MAAKX;AAAA;AADQ,SAAAK,OAAAO,cAAA;AAU9C,SAAA,6BACE,UAAC,oBAAA,UAAA,EAAeA,mBAAY,CAAA,KADpBA,aAAYxC,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 { useGraphiQL, 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 // TODO: maybe can be refactored to Object.values(fieldMap) ?\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 )}\n {deprecatedValues.length > 0 &&\n (showDeprecated || !values.length ? (\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 </>\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 )}\n {value.deprecationReason && (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n )}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const schema = useGraphiQL(state => state.schema);\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","useGraphiQL","_temp7","isAbstractType","getPossibleTypes","_temp8","implementedInterface","field_0","field_1","value_0","value_1","state","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;A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
11
11
|
const {
|
|
12
12
|
push
|
|
13
13
|
} = useDocExplorerActions();
|
|
14
|
-
if (!type) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
14
|
let t1;
|
|
18
15
|
if ($[0] !== push) {
|
|
19
|
-
t1 = (
|
|
16
|
+
t1 = (def) => /* @__PURE__ */ jsx("a", { className: "graphiql-doc-explorer-type-name", onClick: (event) => {
|
|
20
17
|
event.preventDefault();
|
|
21
18
|
push({
|
|
22
|
-
name:
|
|
23
|
-
def
|
|
19
|
+
name: def.name,
|
|
20
|
+
def
|
|
24
21
|
});
|
|
25
|
-
}, href: "#", children:
|
|
22
|
+
}, href: "#", children: def.name });
|
|
26
23
|
$[0] = push;
|
|
27
24
|
$[1] = t1;
|
|
28
25
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport { useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n\n
|
|
1
|
+
{"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport { useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n\n return renderType(type, def => (\n <a\n className=\"graphiql-doc-explorer-type-name\"\n onClick={event => {\n event.preventDefault();\n push({ name: def.name, def });\n }}\n href=\"#\"\n >\n {def.name}\n </a>\n ));\n};\n"],"names":["TypeLink","t0","$","_c","type","push","useDocExplorerActions","t1","def","event","preventDefault","name","t2","renderType"],"mappings":";;;;;AAaO,MAAMA,WAA8BC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAC1C,QAAA;AAAA,IAAAI;AAAAA,MAAiBC,sBAAsB;AAAEC,MAAAA;AAAAL,MAAAA,SAAAG,MAAA;AAEjBE,SAAAC,SACtB,oBAAA,KAAA,EACY,WAAA,mCACD,SAAAC,CAAA,UAAA;AACPA,YAAKC,eAAgB;AACjB,WAAA;AAAA,QAAAC,MAASH,IAAGG;AAAAA,QAAAH;AAAAA,MAAAA,CAAY;AAAA,IAEzB,GAAA,MAAA,KAEJA,UAAAA,IAAGG,KACN,CAAA;AACDT,WAAAG;AAAAH,WAAAK;AAAAA,EAAAA,OAAA;AAAAA,SAAAL,EAAA,CAAA;AAAA,EAAA;AAAAU,MAAAA;AAAA,MAAAV,EAAAK,CAAAA,MAAAA,MAAAL,SAAAE,MAAA;AAXMS,SAAAA,WAAWT,MAAMG,EAWvB;AAACL,WAAAK;AAAAL,WAAAE;AAAAF,WAAAU;AAAAA,EAAAA,OAAA;AAAAA,SAAAV,EAAA,CAAA;AAAA,EAAA;AAXKU,SAAAA;AAWL;"}
|
package/dist/context.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from "react-compiler-runtime";
|
|
2
2
|
import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { pick, useGraphiQL, createBoundedUseStore } from "@graphiql/react";
|
|
5
5
|
import { createStore } from "zustand";
|
|
6
6
|
import { getSchemaReference } from "./schema-reference.js";
|
|
7
7
|
const INITIAL_NAV_STACK = [{
|
|
@@ -153,37 +153,44 @@ const docExplorerStore = createStore((set, get) => ({
|
|
|
153
153
|
}
|
|
154
154
|
}));
|
|
155
155
|
const DocExplorerStore = (t0) => {
|
|
156
|
-
const $ = c(
|
|
156
|
+
const $ = c(8);
|
|
157
157
|
const {
|
|
158
158
|
children
|
|
159
159
|
} = t0;
|
|
160
|
+
let t1;
|
|
161
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
162
|
+
t1 = pick("schema", "validationErrors", "schemaReference");
|
|
163
|
+
$[0] = t1;
|
|
164
|
+
} else {
|
|
165
|
+
t1 = $[0];
|
|
166
|
+
}
|
|
160
167
|
const {
|
|
161
168
|
schema,
|
|
162
169
|
validationErrors,
|
|
163
170
|
schemaReference
|
|
164
|
-
} =
|
|
165
|
-
let t1;
|
|
171
|
+
} = useGraphiQL(t1);
|
|
166
172
|
let t2;
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
let t3;
|
|
174
|
+
if ($[1] !== schemaReference) {
|
|
175
|
+
t2 = () => {
|
|
169
176
|
const {
|
|
170
177
|
resolveSchemaReferenceToNavItem
|
|
171
178
|
} = docExplorerStore.getState().actions;
|
|
172
179
|
resolveSchemaReferenceToNavItem(schemaReference);
|
|
173
180
|
};
|
|
174
|
-
|
|
175
|
-
$[
|
|
176
|
-
$[1] = t1;
|
|
181
|
+
t3 = [schemaReference];
|
|
182
|
+
$[1] = schemaReference;
|
|
177
183
|
$[2] = t2;
|
|
184
|
+
$[3] = t3;
|
|
178
185
|
} else {
|
|
179
|
-
t1 = $[1];
|
|
180
186
|
t2 = $[2];
|
|
187
|
+
t3 = $[3];
|
|
181
188
|
}
|
|
182
|
-
useEffect(
|
|
183
|
-
let t3;
|
|
189
|
+
useEffect(t2, t3);
|
|
184
190
|
let t4;
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
let t5;
|
|
192
|
+
if ($[4] !== schema || $[5] !== validationErrors) {
|
|
193
|
+
t4 = () => {
|
|
187
194
|
const {
|
|
188
195
|
reset,
|
|
189
196
|
rebuildNavStackWithSchema
|
|
@@ -194,16 +201,16 @@ const DocExplorerStore = (t0) => {
|
|
|
194
201
|
rebuildNavStackWithSchema(schema);
|
|
195
202
|
}
|
|
196
203
|
};
|
|
197
|
-
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[5] = t3;
|
|
204
|
+
t5 = [schema, validationErrors];
|
|
205
|
+
$[4] = schema;
|
|
206
|
+
$[5] = validationErrors;
|
|
201
207
|
$[6] = t4;
|
|
208
|
+
$[7] = t5;
|
|
202
209
|
} else {
|
|
203
|
-
t3 = $[5];
|
|
204
210
|
t4 = $[6];
|
|
211
|
+
t5 = $[7];
|
|
205
212
|
}
|
|
206
|
-
useEffect(
|
|
213
|
+
useEffect(t4, t5);
|
|
207
214
|
return children;
|
|
208
215
|
};
|
|
209
216
|
const useDocExplorerStore = createBoundedUseStore(docExplorerStore);
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../src/context.ts"],"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 { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport {\n SchemaReference,\n useSchemaStore,\n createBoundedUseStore,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\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 DocExplorerStoreType = {\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: SchemaReference | null,\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\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Docs' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(\n (set, get) => ({\n explorerNavStack: INITIAL_NAV_STACK,\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 = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n const { push } = get().actions;\n switch (ref.kind) {\n case 'Type': {\n push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n push({\n name: ref.type.name,\n def: ref.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 state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\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 DocExplorerStore: FC<{\n children: ReactNode;\n}> = ({ children }) => {\n const { schema, validationErrors, schemaReference } = useSchemaStore();\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.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 children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"names":["INITIAL_NAV_STACK","name","docExplorerStore","createStore","set","get","explorerNavStack","actions","push","item","state","curr","lastItem","at","def","pop","length","slice","reset","resolveSchemaReferenceToNavItem","schemaReference","kind","typeInfo","ref","getSchemaReference","type","field","rebuildNavStackWithSchema","schema","oldNavStack","newNavStack","lastEntity","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","args","some","a","DocExplorerStore","t0","$","_c","children","validationErrors","useSchemaStore","t1","t2","getState","useEffect","t3","t4","useDocExplorerStore","createBoundedUseStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"mappings":";;;;;;AA+EA,MAAMA,oBAAyC,CAAC;AAAA,EAAEC,MAAM;AAAO,CAAC;AAEzD,MAAMC,mBAAmBC,YAC9B,CAACC,KAAKC,SAAS;AAAA,EACbC,kBAAkBN;AAAAA,EAClBO,SAAS;AAAA,IACPC,KAAKC,MAAM;AACTL,UAAIM,CAAS,UAAA;AACX,cAAMC,OAAOD,MAAMJ;AACbM,cAAAA,WAAWD,KAAKE,GAAG,EAAE;AACrBP,cAAAA;AAAAA;AAAAA,UAEJM,SAASE,QAA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AAAAA,MAAAA,IACEzB,iBAAAoD,SAAAA,EAA2B/C;AAAS,UAGlCqB,UAAc,QAAIsB,iBAAgBlC,SAAW,GAAA;AACzC,cAAA;AAAA,MAAA,OAAC;AAEPW,kCAA0BC,MAAM;AAAA,MAAA;AAAA,IAAC;AAElC,SAAA,CAACA,QAAQsB,gBAAgB;AAACH,WAAAnB;AAAAmB,WAAAG;AAAAH,WAAAS;AAAAT,WAAAU;AAAAA,EAAAA,OAAA;AAAAD,SAAAT,EAAA,CAAA;AAAAU,SAAAV,EAAA,CAAA;AAAA,EAAA;AAV7BQ,YAAUC,IAUPC,EAA0B;AAEtBR,SAAAA;AAAwB;AAGjC,MAAMS,sBAAsBC,sBAAsBzD,gBAAgB;AAE3D,MAAM0D,iBAAiBA,MAAA;AAAA,SAC5BF,oBAAAG,KAAmD;AAAC;AAC/C,MAAMC,wBAAwBA,MAAA;AAAA,SACnCJ,oBAAAK,MAA0C;AAAC;AAHf,SAAAF,MAAAnD,OAAA;AAAA,SACCA,MAAKJ;AAAA;AACC,SAAAyD,OAAArD,OAAA;AAAA,SACNA,MAAKH;AAAA;"}
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../src/context.ts"],"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 { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport {\n SchemaReference,\n useGraphiQL,\n pick,\n createBoundedUseStore,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\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 DocExplorerStoreType = {\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: SchemaReference | null,\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\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Docs' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(\n (set, get) => ({\n explorerNavStack: INITIAL_NAV_STACK,\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 = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n const { push } = get().actions;\n switch (ref.kind) {\n case 'Type': {\n push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n push({\n name: ref.type.name,\n def: ref.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 state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\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 DocExplorerStore: FC<{\n children: ReactNode;\n}> = ({ children }) => {\n const { schema, validationErrors, schemaReference } = useGraphiQL(\n pick('schema', 'validationErrors', 'schemaReference'),\n );\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.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 children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"names":["INITIAL_NAV_STACK","name","docExplorerStore","createStore","set","get","explorerNavStack","actions","push","item","state","curr","lastItem","at","def","pop","length","slice","reset","resolveSchemaReferenceToNavItem","schemaReference","kind","typeInfo","ref","getSchemaReference","type","field","rebuildNavStackWithSchema","schema","oldNavStack","newNavStack","lastEntity","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","args","some","a","DocExplorerStore","t0","$","_c","children","t1","Symbol","for","pick","validationErrors","useGraphiQL","t2","t3","getState","useEffect","t4","t5","useDocExplorerStore","createBoundedUseStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"mappings":";;;;;;AAgFA,MAAMA,oBAAyC,CAAC;AAAA,EAAEC,MAAM;AAAO,CAAC;AAEzD,MAAMC,m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{
|
|
2
|
+
import { useGraphiQL, DocsFilledIcon, DocsIcon } from "@graphiql/react";
|
|
3
3
|
import { DocExplorerStore, useDocExplorer, useDocExplorerActions } from "./context.js";
|
|
4
4
|
import { DocExplorer } from "./components/doc-explorer.js";
|
|
5
5
|
import { Argument } from "./components/argument.js";
|
|
@@ -16,7 +16,7 @@ import { TypeLink } from "./components/type-link.js";
|
|
|
16
16
|
const DOC_EXPLORER_PLUGIN = {
|
|
17
17
|
title: "Documentation Explorer",
|
|
18
18
|
icon: function Icon() {
|
|
19
|
-
const visiblePlugin =
|
|
19
|
+
const visiblePlugin = useGraphiQL((state) => state.visiblePlugin);
|
|
20
20
|
return visiblePlugin === DOC_EXPLORER_PLUGIN ? /* @__PURE__ */ jsx(DocsFilledIcon, {}) : /* @__PURE__ */ jsx(DocsIcon, {});
|
|
21
21
|
},
|
|
22
22
|
content: DocExplorer
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n DocsFilledIcon,\n DocsIcon,\n GraphiQLPlugin,\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n DocsFilledIcon,\n DocsIcon,\n GraphiQLPlugin,\n useGraphiQL,\n} from '@graphiql/react';\nimport { DocExplorer } from './components';\n\nexport * from './components';\n\nexport {\n DocExplorerStore,\n useDocExplorer,\n useDocExplorerActions,\n} from './context';\n\nexport type {\n DocExplorerFieldDef,\n DocExplorerNavStack,\n DocExplorerNavStackItem,\n} from './context';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const visiblePlugin = useGraphiQL(state => state.visiblePlugin);\n return visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n"],"names":["DOC_EXPLORER_PLUGIN","title","icon","Icon","visiblePlugin","useGraphiQL","state","content","DocExplorer"],"mappings":";;;;;;;;;;;;;;;AAsBO,MAAMA,sBAAsC;AAAA,EACjDC,OAAO;AAAA,EACPC,MAAM,SAASC,OAAO;AACpB,UAAMC,gBAAgBC,YAAYC,CAASA,UAAAA,MAAMF,aAAa;AAC9D,WAAOA,kBAAkBJ,sBACvB,oBAAC,gBAAiB,CAAA,CAAA,wBAEjB,UACF,EAAA;AAAA,EACH;AAAA,EACAO,SAASC;AACX;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphiql/plugin-doc-explorer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-canary-75298f4c.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-dom": "^18 || ^19"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@graphiql/react": "^0.
|
|
44
|
+
"@graphiql/react": "^0.36.0-canary-75298f4c.0",
|
|
45
45
|
"@headlessui/react": "^2.2",
|
|
46
46
|
"react-compiler-runtime": "19.1.0-rc.1",
|
|
47
47
|
"zustand": "^5"
|