ruru-components 2.0.0-beta.7 → 2.0.0-beta.9
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 +23 -0
- package/dist/interfaces.d.ts +18 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/ruru.d.ts +2 -0
- package/dist/ruru.d.ts.map +1 -1
- package/dist/ruru.js +7 -6
- package/dist/ruru.js.map +1 -1
- package/package.json +2 -2
- package/dist/hooks/useSchema.d.ts +0 -8
- package/dist/hooks/useSchema.d.ts.map +0 -1
- package/dist/hooks/useSchema.js +0 -70
- package/dist/hooks/useSchema.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# ruru-components
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1833](https://github.com/graphile/crystal/pull/1833)
|
|
8
|
+
[`11ceb1753`](https://github.com/graphile/crystal/commit/11ceb1753ee42ee6d991e618dedc670a6f238fab)
|
|
9
|
+
Thanks [@benjie](https://github.com/benjie)! - Rework how schema fetching
|
|
10
|
+
works to solve issue with headers not being sent. Thanks @JoviDeCroock for the
|
|
11
|
+
inspiration.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
[[`49fcb0d58`](https://github.com/graphile/crystal/commit/49fcb0d585b31b291c9072c339d6f5b550eefc9f)]:
|
|
14
|
+
- grafast@0.1.1-beta.1
|
|
15
|
+
|
|
16
|
+
## 2.0.0-beta.8
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#1799](https://github.com/graphile/crystal/pull/1799)
|
|
21
|
+
[`3dd5d86d6`](https://github.com/graphile/crystal/commit/3dd5d86d6c1ea7ba106c08e8a315ec47ed6cfa2d)
|
|
22
|
+
Thanks [@jvandermey](https://github.com/jvandermey)! - Can now pass onEdit
|
|
23
|
+
callbacks through the Ruru config via the plugin system; e.g. to update the
|
|
24
|
+
URL search params with the current editor state.
|
|
25
|
+
|
|
3
26
|
## 2.0.0-beta.7
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -27,12 +27,28 @@ export interface RuruProps {
|
|
|
27
27
|
*/
|
|
28
28
|
defaultQuery?: string;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* @deprecated Use `query` instead
|
|
31
31
|
*/
|
|
32
32
|
initialQuery?: string;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* @deprecated Use `variables` instead
|
|
35
35
|
*/
|
|
36
36
|
initialVariables?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The query to prepopulate the editor with.
|
|
39
|
+
*/
|
|
40
|
+
query?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The variables to prepopulate the editor with.
|
|
43
|
+
*/
|
|
44
|
+
variables?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Callback executed when the current query changes.
|
|
47
|
+
*/
|
|
48
|
+
onEditQuery?: GraphiQLProps["onEditQuery"];
|
|
49
|
+
/**
|
|
50
|
+
* Callback executed when the variables change.
|
|
51
|
+
*/
|
|
52
|
+
onEditVariables?: GraphiQLProps["onEditVariables"];
|
|
37
53
|
}
|
|
38
54
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,Q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;OAEG;IACH,eAAe,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACpD"}
|
package/dist/ruru.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export declare const RuruInner: FC<{
|
|
|
9
9
|
error: Error | null;
|
|
10
10
|
setError: React.Dispatch<React.SetStateAction<Error | null>>;
|
|
11
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":"AAcA,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;AAWjD,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAsD9B,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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { explorerPlugin as makeExplorerPlugin } from "@graphiql/plugin-explorer";
|
|
3
|
-
import { CopyIcon, GraphiQLProvider as GP2, MergeIcon, PrettifyIcon, SettingsIcon, ToolbarButton, ToolbarMenu, useCopyQuery, useMergeQuery, } from "@graphiql/react";
|
|
3
|
+
import { CopyIcon, GraphiQLProvider as GP2, MergeIcon, PrettifyIcon, SettingsIcon, ToolbarButton, ToolbarMenu, useCopyQuery, useMergeQuery, useSchemaContext, } from "@graphiql/react";
|
|
4
4
|
import { GraphiQL, GraphiQLInterface, GraphiQLProvider } from "graphiql";
|
|
5
5
|
import { useCallback, useMemo, useState } from "react";
|
|
6
6
|
import { ErrorPopup } from "./components/ErrorPopup.js";
|
|
@@ -8,8 +8,8 @@ import { RuruFooter } from "./components/Footer.js";
|
|
|
8
8
|
import { defaultQuery as DEFAULT_QUERY } from "./defaultQuery.js";
|
|
9
9
|
import { ExplainContext, useExplain } from "./hooks/useExplain.js";
|
|
10
10
|
import { useFetcher } from "./hooks/useFetcher.js";
|
|
11
|
+
import { useGraphQLChangeStream } from "./hooks/useGraphQLChangeStream.js";
|
|
11
12
|
import { usePrettify } from "./hooks/usePrettify.js";
|
|
12
|
-
import { useSchema } from "./hooks/useSchema.js";
|
|
13
13
|
import { useStorage } from "./hooks/useStorage.js";
|
|
14
14
|
import { EXPLAIN_PLUGIN } from "./plugins/explain.js";
|
|
15
15
|
if (GP2 !== GraphiQLProvider) {
|
|
@@ -32,7 +32,6 @@ export const Ruru = (props) => {
|
|
|
32
32
|
});
|
|
33
33
|
const [error, setError] = useState(null);
|
|
34
34
|
const explainHelpers = useExplain(storage);
|
|
35
|
-
const { schema } = useSchema(props, fetcher, setError, streamEndpoint);
|
|
36
35
|
const defaultQuery = props.defaultQuery ?? DEFAULT_QUERY;
|
|
37
36
|
const explorerPlugin = makeExplorerPlugin({
|
|
38
37
|
showAttribution: false,
|
|
@@ -47,13 +46,15 @@ export const Ruru = (props) => {
|
|
|
47
46
|
explain,
|
|
48
47
|
setExplain,
|
|
49
48
|
explainResults,
|
|
50
|
-
}, children: _jsx(GraphiQLProvider, { fetcher: fetcher,
|
|
49
|
+
}, children: _jsx(GraphiQLProvider, { 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 }) }) }));
|
|
51
50
|
};
|
|
52
51
|
export const RuruInner = (props) => {
|
|
53
|
-
const { storage, editorTheme, error, setError, onEditQuery } = props;
|
|
52
|
+
const { storage, editorTheme, error, setError, onEditQuery, onEditVariables, streamEndpoint, } = props;
|
|
54
53
|
const prettify = usePrettify();
|
|
55
54
|
const mergeQuery = useMergeQuery();
|
|
56
55
|
const copyQuery = useCopyQuery();
|
|
56
|
+
const schemaContext = useSchemaContext({ nonNull: true });
|
|
57
|
+
useGraphQLChangeStream(props, schemaContext.introspect, streamEndpoint);
|
|
57
58
|
return (_jsxs("div", { className: "graphiql-container", style: {
|
|
58
59
|
position: "absolute",
|
|
59
60
|
width: "100%",
|
|
@@ -66,6 +67,6 @@ export const RuruInner = (props) => {
|
|
|
66
67
|
flex: "1 1 100%",
|
|
67
68
|
overflow: "hidden",
|
|
68
69
|
position: "relative",
|
|
69
|
-
}, children: _jsxs(GraphiQLInterface, { editorTheme: editorTheme ?? "graphiql", onEditQuery: onEditQuery, 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] }));
|
|
70
|
+
}, 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] }));
|
|
70
71
|
};
|
|
71
72
|
//# 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":";AAAA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EACL,QAAQ,EACR,gBAAgB,IAAI,GAAG,EACvB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ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C,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruru-components",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "Grafast-flavoured GraphiQL distribution; the underlying React components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@graphiql/react": "^0.19.3",
|
|
43
43
|
"@graphiql/toolkit": "^0.9.1",
|
|
44
44
|
"@types/node": "^20.5.7",
|
|
45
|
-
"grafast": "^0.1.1-beta.
|
|
45
|
+
"grafast": "^0.1.1-beta.1",
|
|
46
46
|
"graphiql": "^3.0.5",
|
|
47
47
|
"graphql-ws": "^5.14.0",
|
|
48
48
|
"react": "^18.2.0",
|
|
@@ -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,70 +0,0 @@
|
|
|
1
|
-
import { isAsyncIterable } from "@graphiql/toolkit";
|
|
2
|
-
import { buildClientSchema, getIntrospectionQuery, GraphQLError, } from "graphql";
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
// import { updateGraphiQLDocExplorerNavStack } from "../updateGraphiQLDocExplorerNavStack.js";
|
|
5
|
-
import { useGraphQLChangeStream } from "./useGraphQLChangeStream.js";
|
|
6
|
-
export const useSchema = (props, fetcher, setError, streamEndpoint) => {
|
|
7
|
-
const [schema, setSchema] = useState(null);
|
|
8
|
-
const refetchStatusRef = useRef({
|
|
9
|
-
inProgress: false,
|
|
10
|
-
fetchAgain: null,
|
|
11
|
-
});
|
|
12
|
-
const refetch = useCallback(() => {
|
|
13
|
-
if (refetchStatusRef.current.inProgress) {
|
|
14
|
-
refetchStatusRef.current.fetchAgain = refetch;
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
refetchStatusRef.current.inProgress = true;
|
|
18
|
-
refetchStatusRef.current.fetchAgain = null;
|
|
19
|
-
(async () => {
|
|
20
|
-
// Fetch the schema using our introspection query and report once that has
|
|
21
|
-
// finished.
|
|
22
|
-
const result = await fetcher({
|
|
23
|
-
query: getIntrospectionQuery(),
|
|
24
|
-
operationName: null,
|
|
25
|
-
});
|
|
26
|
-
let payload;
|
|
27
|
-
if (isAsyncIterable(result)) {
|
|
28
|
-
// Handle async iterator; we're only expecting a single payload.
|
|
29
|
-
for await (const entry of result) {
|
|
30
|
-
payload = entry;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
payload = result;
|
|
35
|
-
}
|
|
36
|
-
const { data, errors } = payload;
|
|
37
|
-
if (errors) {
|
|
38
|
-
if (errors[0]) {
|
|
39
|
-
throw new GraphQLError(errors[0].message ?? "Error has no message?!", null, null, null, errors[0].path, null, errors[0].extensions);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
throw new Error("'errors' was set on the payload, but was empty or contained null? This is forbidden by the GraphQL spec.");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// Use the data we got back from GraphQL to build a client schema (a
|
|
46
|
-
// schema without resolvers).
|
|
47
|
-
const schema = buildClientSchema(data);
|
|
48
|
-
setSchema(schema);
|
|
49
|
-
setError(null);
|
|
50
|
-
console.log("Ruru: Schema updated");
|
|
51
|
-
})()
|
|
52
|
-
.catch((error) => {
|
|
53
|
-
console.error("Error occurred when updating the schema:");
|
|
54
|
-
console.error(error);
|
|
55
|
-
setError(new Error(`Introspecting the GraphQL schema failed; please check the endpoint and try again.\n${String(error)}`));
|
|
56
|
-
})
|
|
57
|
-
.finally(() => {
|
|
58
|
-
refetchStatusRef.current.inProgress = false;
|
|
59
|
-
if (refetchStatusRef.current.fetchAgain) {
|
|
60
|
-
refetchStatusRef.current.fetchAgain();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}, [fetcher, setError]);
|
|
64
|
-
useGraphQLChangeStream(props, refetch, streamEndpoint);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
refetch();
|
|
67
|
-
}, [refetch]);
|
|
68
|
-
return { schema };
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=useSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSchema.js","sourceRoot":"","sources":["../../src/hooks/useSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjE,+FAA+F;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,OAAiC,EACjC,QAAgD,EAChD,cAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAuB,IAAI,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAG,MAAM,CAAC;QAC9B,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAA6B;KAC1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