ruru-components 2.0.0-beta.2 → 2.0.0-beta.21
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/CHANGELOG.md +265 -0
- package/dist/components/Copy.d.ts +2 -1
- package/dist/components/Copy.d.ts.map +1 -1
- package/dist/components/Copy.js +8 -11
- package/dist/components/Copy.js.map +1 -1
- package/dist/components/ErrorPopup.js +2 -6
- package/dist/components/ErrorPopup.js.map +1 -1
- package/dist/components/Explain.d.ts +5 -0
- package/dist/components/Explain.d.ts.map +1 -1
- package/dist/components/Explain.js +46 -46
- package/dist/components/Explain.js.map +1 -1
- package/dist/components/Footer.js +2 -6
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/FormatSQL.js +13 -17
- package/dist/components/FormatSQL.js.map +1 -1
- package/dist/components/Mermaid.d.ts +2 -1
- package/dist/components/Mermaid.d.ts.map +1 -1
- package/dist/components/Mermaid.js +24 -17
- package/dist/components/Mermaid.js.map +1 -1
- package/dist/defaultQuery.js +1 -4
- package/dist/defaultQuery.js.map +1 -1
- package/dist/hooks/useExplain.d.ts +1 -1
- package/dist/hooks/useExplain.js +9 -13
- package/dist/hooks/useExplain.js.map +1 -1
- package/dist/hooks/useFetcher.d.ts +5 -4
- package/dist/hooks/useFetcher.d.ts.map +1 -1
- package/dist/hooks/useFetcher.js +26 -36
- package/dist/hooks/useFetcher.js.map +1 -1
- package/dist/hooks/useGraphQLChangeStream.js +6 -10
- package/dist/hooks/useGraphQLChangeStream.js.map +1 -1
- package/dist/hooks/usePrettify.js +6 -10
- package/dist/hooks/usePrettify.js.map +1 -1
- package/dist/hooks/useStorage.d.ts +0 -2
- package/dist/hooks/useStorage.d.ts.map +1 -1
- package/dist/hooks/useStorage.js +5 -11
- package/dist/hooks/useStorage.js.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +27 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js +1 -2
- package/dist/plugins/explain.js +9 -12
- package/dist/plugins/explain.js.map +1 -1
- package/dist/ruru.d.ts +3 -1
- package/dist/ruru.d.ts.map +1 -1
- package/dist/ruru.js +44 -48
- package/dist/ruru.js.map +1 -1
- package/package.json +30 -23
- package/dist/hooks/useSchema.d.ts +0 -8
- package/dist/hooks/useSchema.d.ts.map +0 -1
- package/dist/hooks/useSchema.js +0 -74
- package/dist/hooks/useSchema.js.map +0 -1
package/dist/ruru.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare const RuruInner: FC<{
|
|
|
8
8
|
storage: RuruStorage;
|
|
9
9
|
error: Error | null;
|
|
10
10
|
setError: React.Dispatch<React.SetStateAction<Error | null>>;
|
|
11
|
-
onEditQuery
|
|
11
|
+
onEditQuery?: GraphiQLProps["onEditQuery"];
|
|
12
|
+
onEditVariables?: GraphiQLProps["onEditVariables"];
|
|
13
|
+
streamEndpoint: string | null;
|
|
12
14
|
}>;
|
|
13
15
|
//# sourceMappingURL=ruru.d.ts.map
|
package/dist/ruru.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruru.d.ts","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ruru.d.ts","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAUhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgBjD,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAkD9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7D,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC3C,eAAe,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACnD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CA2HA,CAAC"}
|
package/dist/ruru.js
CHANGED
|
@@ -1,74 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { explorerPlugin as makeExplorerPlugin } from "@graphiql/plugin-explorer";
|
|
3
|
+
import { CopyIcon, GraphiQLProvider as GP2, MergeIcon, PrettifyIcon, SettingsIcon, ToolbarButton, ToolbarMenu, useCopyQuery, useMergeQuery, useSchemaContext, } from "@graphiql/react";
|
|
4
|
+
import { GraphiQL, GraphiQLInterface, GraphiQLProvider } from "graphiql";
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
import { ErrorPopup } from "./components/ErrorPopup.js";
|
|
7
|
+
import { RuruFooter } from "./components/Footer.js";
|
|
8
|
+
import { defaultQuery as DEFAULT_QUERY } from "./defaultQuery.js";
|
|
9
|
+
import { ExplainContext, useExplain } from "./hooks/useExplain.js";
|
|
10
|
+
import { useFetcher } from "./hooks/useFetcher.js";
|
|
11
|
+
import { useGraphQLChangeStream } from "./hooks/useGraphQLChangeStream.js";
|
|
12
|
+
import { usePrettify } from "./hooks/usePrettify.js";
|
|
13
|
+
import { useStorage } from "./hooks/useStorage.js";
|
|
14
|
+
import { EXPLAIN_PLUGIN } from "./plugins/explain.js";
|
|
15
|
+
if (GP2 !== GraphiQLProvider) {
|
|
16
|
+
throw new Error("PACKAGE MANAGEMENT ERROR! The providers don't match up!");
|
|
17
|
+
}
|
|
18
18
|
const checkCss = { width: "1.5rem", display: "inline-block" };
|
|
19
|
-
const check = (
|
|
20
|
-
const nocheck = (
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const check = _jsx("span", { style: checkCss, children: "\u2714" });
|
|
20
|
+
const nocheck = _jsx("span", { style: checkCss });
|
|
21
|
+
const explorerPlugin = makeExplorerPlugin({
|
|
22
|
+
showAttribution: false,
|
|
23
|
+
});
|
|
24
|
+
const plugins = [explorerPlugin, EXPLAIN_PLUGIN];
|
|
25
|
+
export const Ruru = (props) => {
|
|
26
|
+
const storage = useStorage();
|
|
23
27
|
const explain = storage.get("explain") === "true";
|
|
24
28
|
const verbose = storage.get("verbose") === "true";
|
|
25
29
|
const saveHeaders = storage.get("saveHeaders") === "true";
|
|
26
|
-
const setExplain =
|
|
30
|
+
const setExplain = useCallback((newExplain) => {
|
|
27
31
|
storage.set("explain", newExplain ? "true" : "");
|
|
28
32
|
}, [storage]);
|
|
29
|
-
const { fetcher, explainResults, streamEndpoint } =
|
|
33
|
+
const { fetcher, explainResults, streamEndpoint } = useFetcher(props, {
|
|
30
34
|
explain,
|
|
31
35
|
verbose,
|
|
32
36
|
});
|
|
33
|
-
const [error, setError] =
|
|
34
|
-
const explainHelpers =
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
query,
|
|
40
|
-
onEdit: setQuery,
|
|
41
|
-
showAttribution: false,
|
|
42
|
-
});
|
|
43
|
-
const plugins = (0, react_2.useMemo)(() => {
|
|
44
|
-
return [explorerPlugin, explain_js_1.EXPLAIN_PLUGIN];
|
|
45
|
-
}, [explorerPlugin]);
|
|
46
|
-
return ((0, jsx_runtime_1.jsx)(useExplain_js_1.ExplainContext.Provider, { value: {
|
|
37
|
+
const [error, setError] = useState(null);
|
|
38
|
+
const explainHelpers = useExplain(storage);
|
|
39
|
+
const defaultQuery = props.defaultQuery ?? DEFAULT_QUERY;
|
|
40
|
+
return (
|
|
41
|
+
//EditorContextProvider
|
|
42
|
+
_jsx(ExplainContext.Provider, { value: {
|
|
47
43
|
explainHelpers,
|
|
48
44
|
explain,
|
|
49
45
|
setExplain,
|
|
50
46
|
explainResults,
|
|
51
|
-
}, children: (
|
|
47
|
+
}, children: _jsx(GraphiQLProvider, { inputValueDeprecation: true, schemaDescription: true, fetcher: fetcher, defaultQuery: defaultQuery, query: props.query ?? props.initialQuery, variables: props.variables ?? props.initialVariables, plugins: plugins, shouldPersistHeaders: saveHeaders, children: _jsx(RuruInner, { storage: storage, editorTheme: props.editorTheme, error: error, setError: setError, onEditQuery: props.onEditQuery, onEditVariables: props.onEditVariables, streamEndpoint: streamEndpoint }) }) }));
|
|
52
48
|
};
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
49
|
+
export const RuruInner = (props) => {
|
|
50
|
+
const { storage, editorTheme, error, setError, onEditQuery, onEditVariables, streamEndpoint, } = props;
|
|
51
|
+
const prettify = usePrettify();
|
|
52
|
+
const mergeQuery = useMergeQuery();
|
|
53
|
+
const copyQuery = useCopyQuery();
|
|
54
|
+
const schemaContext = useSchemaContext({ nonNull: true });
|
|
55
|
+
useGraphQLChangeStream(props, schemaContext.introspect, streamEndpoint);
|
|
56
|
+
return (_jsxs("div", { className: "graphiql-container", style: {
|
|
60
57
|
position: "absolute",
|
|
61
58
|
width: "100%",
|
|
62
59
|
height: "100%",
|
|
63
60
|
display: "flex",
|
|
64
61
|
flexDirection: "column",
|
|
65
62
|
overflow: "hidden",
|
|
66
|
-
}, children: [(
|
|
63
|
+
}, children: [_jsx("div", { style: {
|
|
67
64
|
display: "flex",
|
|
68
65
|
flex: "1 1 100%",
|
|
69
66
|
overflow: "hidden",
|
|
70
67
|
position: "relative",
|
|
71
|
-
}, children: (
|
|
68
|
+
}, children: _jsxs(GraphiQLInterface, { editorTheme: editorTheme ?? "graphiql", onEditQuery: onEditQuery, onEditVariables: onEditVariables, children: [_jsx(GraphiQL.Logo, { children: _jsx("a", { href: "https://grafast.org/ruru", style: { textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: "Ruru" }) }), _jsxs(GraphiQL.Toolbar, { children: [_jsx(ToolbarButton, { onClick: prettify, label: "Prettify Query (Shift-Ctrl-P)", children: _jsx(PrettifyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), _jsx(ToolbarButton, { onSelect: mergeQuery, label: "Merge Query (Shift-Ctrl-M)", children: _jsx(MergeIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), _jsx(ToolbarButton, { onClick: copyQuery, label: "Copy query (Shift-Ctrl-C)", children: _jsx(CopyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), _jsxs(ToolbarMenu, { label: "Options", button: _jsx(ToolbarButton, { label: "Options", children: _jsx(SettingsIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), children: [_jsx(ToolbarMenu.Item, { title: "View the SQL statements that this query invokes", onSelect: () => storage.toggle("explain"), children: _jsxs("span", { children: [storage.get("explain") === "true" ? check : nocheck, "Explain (if supported)"] }) }), _jsx(ToolbarMenu.Item, { title: "Don't hide explain from results", onSelect: () => storage.toggle("verbose"), children: _jsxs("span", { children: [storage.get("verbose") === "true" ? check : nocheck, "Verbose"] }) }), _jsx(ToolbarMenu.Item, { title: "Should we persist the headers to localStorage? Header editor is next to variable editor at the bottom.", onSelect: () => storage.toggle("saveHeaders"), children: _jsxs("span", { children: [storage.get("saveHeaders") === "true" ? check : nocheck, "Save headers"] }) })] })] }), _jsx(GraphiQL.Footer, { children: _jsx(RuruFooter, {}) })] }) }), error ? (_jsx(ErrorPopup, { error: error, onClose: () => setError(null) })) : null] }));
|
|
72
69
|
};
|
|
73
|
-
exports.RuruInner = RuruInner;
|
|
74
70
|
//# sourceMappingURL=ruru.js.map
|
package/dist/ruru.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruru.js","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ruru.js","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EACL,QAAQ,EACR,gBAAgB,IAAI,GAAG,EACvB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,IAAI,GAAG,KAAK,gBAAgB,EAAE;IAC5B,MAAM,I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EAAC,iDAAiD,EACvD,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,YAEzC,2BACG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,8BAE/C,GACU,EACnB,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAC,iCAAiC,EACvC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,YAEzC,2BACG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,eAE/C,GACU,EACnB,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAC,wGAAwG,EAC9G,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAE7C,2BACG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAEnD,GACU,IACP,IACG,EACnB,KAAC,QAAQ,CAAC,MAAM,cACd,KAAC,UAAU,KAAG,GACE,IACA,GAChB,EACL,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,UAAU,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAI,CAC5D,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruru-components",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
4
|
"description": "Grafast-flavoured GraphiQL distribution; the underlying React components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/graphile/
|
|
23
|
+
"url": "git+https://github.com/graphile/crystal.git"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"graphile",
|
|
@@ -33,26 +34,32 @@
|
|
|
33
34
|
"author": "Benjie Gillam <code@benjiegillam.com>",
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"bugs": {
|
|
36
|
-
"url": "https://github.com/graphile/
|
|
37
|
+
"url": "https://github.com/graphile/crystal/issues"
|
|
37
38
|
},
|
|
38
39
|
"homepage": "https://grafast.org/ruru/",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@graphiql/plugin-explorer": "^0.
|
|
41
|
-
"@graphiql/react": "^0.
|
|
42
|
-
"@graphiql/toolkit": "^0.
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
49
|
-
"tslib": "^2.
|
|
41
|
+
"@graphiql/plugin-explorer": "^1.0.3-canary-64994e0e.0",
|
|
42
|
+
"@graphiql/react": "^0.20.3-canary-64994e0e.0",
|
|
43
|
+
"@graphiql/toolkit": "^0.9.1",
|
|
44
|
+
"@types/node": "^20.5.7",
|
|
45
|
+
"grafast": "^0.1.1-beta.13",
|
|
46
|
+
"graphiql": "^3.1.1-canary-64994e0e.0",
|
|
47
|
+
"graphql-ws": "^5.14.0",
|
|
48
|
+
"react": "^18.2.0",
|
|
49
|
+
"react-dom": "^18.2.0",
|
|
50
|
+
"tslib": "^2.6.2"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": ">=16"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"graphql": "^16.1.0-experimental-stream-defer.6"
|
|
56
|
+
"graphql": "^16.1.0-experimental-stream-defer.6",
|
|
57
|
+
"tamedevil": "^0.0.0-beta.7"
|
|
58
|
+
},
|
|
59
|
+
"peerDependenciesMeta": {
|
|
60
|
+
"tamedevil": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
56
63
|
},
|
|
57
64
|
"files": [
|
|
58
65
|
"dist",
|
|
@@ -60,15 +67,15 @@
|
|
|
60
67
|
"ruru.css"
|
|
61
68
|
],
|
|
62
69
|
"devDependencies": {
|
|
63
|
-
"@types/codemirror": "^5.60.
|
|
64
|
-
"@types/debug": "^4.1.
|
|
65
|
-
"@types/jest": "^
|
|
66
|
-
"@types/nodemon": "1.19.
|
|
67
|
-
"@types/react": "^18",
|
|
68
|
-
"@types/react-dom": "^18.
|
|
70
|
+
"@types/codemirror": "^5.60.9",
|
|
71
|
+
"@types/debug": "^4.1.8",
|
|
72
|
+
"@types/jest": "^29.5.4",
|
|
73
|
+
"@types/nodemon": "1.19.2",
|
|
74
|
+
"@types/react": "^18.2.21",
|
|
75
|
+
"@types/react-dom": "^18.2.7",
|
|
69
76
|
"graphql": "16.1.0-experimental-stream-defer.6",
|
|
70
|
-
"jest": "^
|
|
71
|
-
"nodemon": "^
|
|
72
|
-
"typescript": "^5.
|
|
77
|
+
"jest": "^29.6.4",
|
|
78
|
+
"nodemon": "^3.0.1",
|
|
79
|
+
"typescript": "^5.2.2"
|
|
73
80
|
}
|
|
74
81
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GraphiQLProps } from "graphiql";
|
|
2
|
-
import type { GraphQLSchema } from "graphql";
|
|
3
|
-
import type { Dispatch, SetStateAction } from "react";
|
|
4
|
-
import type { RuruProps } from "../interfaces.js";
|
|
5
|
-
export declare const useSchema: (props: RuruProps, fetcher: GraphiQLProps["fetcher"], setError: Dispatch<SetStateAction<Error | null>>, streamEndpoint: string | null) => {
|
|
6
|
-
schema: GraphQLSchema | null;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=useSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../src/hooks/useSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAM9D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,eAAO,MAAM,SAAS,UACb,SAAS,WACP,aAAa,CAAC,SAAS,CAAC,YACvB,SAAS,eAAe,KAAK,GAAG,IAAI,CAAC,CAAC,kBAChC,MAAM,GAAG,IAAI;;CAkF9B,CAAC"}
|
package/dist/hooks/useSchema.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSchema = void 0;
|
|
4
|
-
const toolkit_1 = require("@graphiql/toolkit");
|
|
5
|
-
const graphql_1 = require("graphql");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
// import { updateGraphiQLDocExplorerNavStack } from "../updateGraphiQLDocExplorerNavStack.js";
|
|
8
|
-
const useGraphQLChangeStream_js_1 = require("./useGraphQLChangeStream.js");
|
|
9
|
-
const useSchema = (props, fetcher, setError, streamEndpoint) => {
|
|
10
|
-
const [schema, setSchema] = (0, react_1.useState)(null);
|
|
11
|
-
const refetchStatusRef = (0, react_1.useRef)({
|
|
12
|
-
inProgress: false,
|
|
13
|
-
fetchAgain: null,
|
|
14
|
-
});
|
|
15
|
-
const refetch = (0, react_1.useCallback)(() => {
|
|
16
|
-
if (refetchStatusRef.current.inProgress) {
|
|
17
|
-
refetchStatusRef.current.fetchAgain = refetch;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
refetchStatusRef.current.inProgress = true;
|
|
21
|
-
refetchStatusRef.current.fetchAgain = null;
|
|
22
|
-
(async () => {
|
|
23
|
-
// Fetch the schema using our introspection query and report once that has
|
|
24
|
-
// finished.
|
|
25
|
-
const result = await fetcher({
|
|
26
|
-
query: (0, graphql_1.getIntrospectionQuery)(),
|
|
27
|
-
operationName: null,
|
|
28
|
-
});
|
|
29
|
-
let payload;
|
|
30
|
-
if ((0, toolkit_1.isAsyncIterable)(result)) {
|
|
31
|
-
// Handle async iterator; we're only expecting a single payload.
|
|
32
|
-
for await (const entry of result) {
|
|
33
|
-
payload = entry;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
payload = result;
|
|
38
|
-
}
|
|
39
|
-
const { data, errors } = payload;
|
|
40
|
-
if (errors) {
|
|
41
|
-
if (errors[0]) {
|
|
42
|
-
throw new graphql_1.GraphQLError(errors[0].message ?? "Error has no message?!", null, null, null, errors[0].path, null, errors[0].extensions);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw new Error("'errors' was set on the payload, but was empty or contained null? This is forbidden by the GraphQL spec.");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Use the data we got back from GraphQL to build a client schema (a
|
|
49
|
-
// schema without resolvers).
|
|
50
|
-
const schema = (0, graphql_1.buildClientSchema)(data);
|
|
51
|
-
setSchema(schema);
|
|
52
|
-
setError(null);
|
|
53
|
-
console.log("Ruru: Schema updated");
|
|
54
|
-
})()
|
|
55
|
-
.catch((error) => {
|
|
56
|
-
console.error("Error occurred when updating the schema:");
|
|
57
|
-
console.error(error);
|
|
58
|
-
setError(new Error(`Introspecting the GraphQL schema failed; please check the endpoint and try again.\n${String(error)}`));
|
|
59
|
-
})
|
|
60
|
-
.finally(() => {
|
|
61
|
-
refetchStatusRef.current.inProgress = false;
|
|
62
|
-
if (refetchStatusRef.current.fetchAgain) {
|
|
63
|
-
refetchStatusRef.current.fetchAgain();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}, [fetcher, setError]);
|
|
67
|
-
(0, useGraphQLChangeStream_js_1.useGraphQLChangeStream)(props, refetch, streamEndpoint);
|
|
68
|
-
(0, react_1.useEffect)(() => {
|
|
69
|
-
refetch();
|
|
70
|
-
}, [refetch]);
|
|
71
|
-
return { schema };
|
|
72
|
-
};
|
|
73
|
-
exports.useSchema = useSchema;
|
|
74
|
-
//# sourceMappingURL=useSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSchema.js","sourceRoot":"","sources":["../../src/hooks/useSchema.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAGpD,qCAIiB;AAEjB,iCAAiE;AAGjE,+FAA+F;AAC/F,2EAAqE;AAE9D,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,OAAiC,EACjC,QAAgD,EAChD,cAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAuB,IAAI,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC;QAC9B,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAA6B;KAC1C,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,IAAI,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE;YACvC,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC;YAC9C,OAAO;SACR;QACD,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC3C,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC3C,CAAC,KAAK,IAAI,EAAE;YACV,0EAA0E;YAC1E,YAAY;YACZ,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;gBAC3B,KAAK,EAAE,IAAA,+BAAqB,GAAE;gB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