@arcblock/graphql-playground 3.0.10 → 3.0.12

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.
Files changed (3) hide show
  1. package/lib/index.js +42 -32
  2. package/package.json +6 -5
  3. package/src/index.jsx +21 -29
package/lib/index.js CHANGED
@@ -1,50 +1,60 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import o from "prop-types";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import r from "prop-types";
3
3
  import { styled as x } from "@arcblock/ux/lib/Theme";
4
4
  import { GraphiQL as h } from "graphiql";
5
- import { explorerPlugin as m } from "@graphiql/plugin-explorer";
6
- import { createGraphiQLFetcher as g } from "@graphiql/toolkit";
7
- import t from "lodash/isUndefined";
5
+ import { explorerPlugin as g } from "@graphiql/plugin-explorer";
6
+ import { createGraphiQLFetcher as m } from "@graphiql/toolkit";
8
7
  import "graphiql/style.css";
9
8
  import "@graphiql/plugin-explorer/style.css";
10
9
  import { mergeProps as b } from "@arcblock/ux/lib/Util";
11
- function a({ ...e }) {
12
- const r = Object.assign({}, e);
13
- t(r.title) && (r.title = "Query"), t(r.defaultQuery) && (r.defaultQuery = "{}"), t(r.persistentQuery) && (r.persistentQuery = !1), t(r.enableQueryComposer) && (r.enableQueryComposer = !0), t(r.enableCodeExporter) && (r.enableCodeExporter = !1), t(r.enableHistory) && (r.enableHistory = !1), t(r.extraCodeSnippets) && (r.extraCodeSnippets = []), t(r.extraHeaders) && (r.extraHeaders = {});
14
- const p = b(r, a, [
10
+ import { Box as c } from "@mui/material";
11
+ function p({ ...e }) {
12
+ const a = Object.assign(
13
+ {
14
+ title: "Query",
15
+ defaultQuery: "{}",
16
+ persistentQuery: !1,
17
+ enableQueryComposer: !0,
18
+ enableCodeExporter: !1,
19
+ enableHistory: !1,
20
+ extraCodeSnippets: [],
21
+ extraHeaders: {}
22
+ },
23
+ e
24
+ ), o = b(a, p, [
15
25
  "style",
16
26
  "persistentQuery",
17
27
  "enableQueryComposer",
18
28
  "enableCodeExporter",
19
29
  "enableHistory"
20
- ]), n = g({
21
- url: p.endpoint
22
- }), l = [m()], {
23
- endpoint: y,
24
- title: f,
25
- enableCodeExporter: C,
26
- enableQueryComposer: w,
27
- enableHistory: $,
30
+ ]), i = typeof o.extraHeaders == "function" ? o.extraHeaders() : o.extraHeaders || {}, n = m({
31
+ url: o.endpoint,
32
+ headers: i
33
+ }), l = [g()], {
34
+ endpoint: f,
35
+ title: C,
36
+ enableCodeExporter: w,
37
+ enableQueryComposer: $,
38
+ enableHistory: k,
28
39
  extraCodeSnippets: Q,
29
40
  defaultQuery: d,
30
- extraHeaders: k,
31
41
  persistentQuery: H,
32
42
  ...s
33
- } = p;
34
- return /* @__PURE__ */ i(c, { ...s, children: /* @__PURE__ */ i(h, { fetcher: n, plugins: l, defaultQuery: d }) });
43
+ } = o;
44
+ return /* @__PURE__ */ t(u, { ...s, children: /* @__PURE__ */ t(h, { fetcher: n, plugins: l, defaultQuery: d }) });
35
45
  }
36
- a.propTypes = {
37
- endpoint: o.string.isRequired,
38
- defaultQuery: o.string,
39
- title: o.string,
40
- persistentQuery: o.bool,
41
- enableQueryComposer: o.bool,
42
- enableCodeExporter: o.bool,
43
- enableHistory: o.bool,
44
- extraCodeSnippets: o.array,
45
- extraHeaders: o.any
46
+ p.propTypes = {
47
+ endpoint: r.string.isRequired,
48
+ defaultQuery: r.string,
49
+ title: r.string,
50
+ persistentQuery: r.bool,
51
+ enableQueryComposer: r.bool,
52
+ enableCodeExporter: r.bool,
53
+ enableHistory: r.bool,
54
+ extraCodeSnippets: r.array,
55
+ extraHeaders: r.any
46
56
  };
47
- const c = x("div")`
57
+ const u = x(c)`
48
58
  display: flex;
49
59
  flex-direction: row;
50
60
  flex: 1;
@@ -233,5 +243,5 @@ const c = x("div")`
233
243
  }
234
244
  `;
235
245
  export {
236
- a as default
246
+ p as default
237
247
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/graphql-playground",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "A React Component to interact with GraphQL APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -30,13 +30,14 @@
30
30
  "url": "https://github.com/ArcBlock/ux/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@graphiql/plugin-explorer": "^4.0.6",
33
+ "@graphiql/plugin-explorer": "^5.0.0",
34
+ "@graphiql/toolkit": "^0.11.3",
34
35
  "axios": "^1.10.0",
35
- "graphiql": "^4.1.2",
36
+ "graphiql": "^5.0.3",
36
37
  "graphql": "^16.11.0"
37
38
  },
38
39
  "peerDependencies": {
39
- "@arcblock/ux": "^3.0.8",
40
+ "@arcblock/ux": "^3.0.10",
40
41
  "@emotion/react": "^11.14.0",
41
42
  "@emotion/styled": "^11.14.0",
42
43
  "react": "^19.0.0",
@@ -49,5 +50,5 @@
49
50
  "eslint-plugin-react-hooks": "^4.6.2",
50
51
  "jest": "^29.7.0"
51
52
  },
52
- "gitHead": "8e4b3b4f9cc52c8f1f1d270ab03a3c566073617a"
53
+ "gitHead": "ebe824e4b0ddfc1cbdd9ffecc22283e57a58c042"
53
54
  }
package/src/index.jsx CHANGED
@@ -4,7 +4,6 @@ import { GraphiQL } from 'graphiql';
4
4
  // eslint-disable-next-line import/no-unresolved
5
5
  import { explorerPlugin } from '@graphiql/plugin-explorer';
6
6
  import { createGraphiQLFetcher } from '@graphiql/toolkit';
7
- import isUndefined from 'lodash/isUndefined';
8
7
 
9
8
  // eslint-disable-next-line import/no-unresolved
10
9
  import 'graphiql/style.css';
@@ -12,33 +11,23 @@ import 'graphiql/style.css';
12
11
  import '@graphiql/plugin-explorer/style.css';
13
12
 
14
13
  import { mergeProps } from '@arcblock/ux/lib/Util';
14
+ import { Box } from '@mui/material';
15
15
 
16
16
  export default function GraphQLPlayground({ ...rawProps }) {
17
- const props = Object.assign({}, rawProps);
18
- if (isUndefined(props.title)) {
19
- props.title = 'Query';
20
- }
21
- if (isUndefined(props.defaultQuery)) {
22
- props.defaultQuery = '{}';
23
- }
24
- if (isUndefined(props.persistentQuery)) {
25
- props.persistentQuery = false;
26
- }
27
- if (isUndefined(props.enableQueryComposer)) {
28
- props.enableQueryComposer = true;
29
- }
30
- if (isUndefined(props.enableCodeExporter)) {
31
- props.enableCodeExporter = false;
32
- }
33
- if (isUndefined(props.enableHistory)) {
34
- props.enableHistory = false;
35
- }
36
- if (isUndefined(props.extraCodeSnippets)) {
37
- props.extraCodeSnippets = [];
38
- }
39
- if (isUndefined(props.extraHeaders)) {
40
- props.extraHeaders = {};
41
- }
17
+ const props = Object.assign(
18
+ {
19
+ title: 'Query',
20
+ defaultQuery: '{}',
21
+ persistentQuery: false,
22
+ enableQueryComposer: true,
23
+ enableCodeExporter: false,
24
+ enableHistory: false,
25
+ extraCodeSnippets: [],
26
+ extraHeaders: {},
27
+ },
28
+ rawProps
29
+ );
30
+
42
31
  const newProps = mergeProps(props, GraphQLPlayground, [
43
32
  'style',
44
33
  'persistentQuery',
@@ -46,13 +35,17 @@ export default function GraphQLPlayground({ ...rawProps }) {
46
35
  'enableCodeExporter',
47
36
  'enableHistory',
48
37
  ]);
38
+ const extraHeaders =
39
+ typeof newProps.extraHeaders === 'function' ? newProps.extraHeaders() : newProps.extraHeaders || {};
49
40
 
50
41
  const fetcher = createGraphiQLFetcher({
51
42
  url: newProps.endpoint,
43
+ headers: extraHeaders,
52
44
  });
53
45
  const explorer = explorerPlugin();
46
+ // FIXME: @zhanghan HISTORY_PLUGIN 会导致 webapp 报错,之后再修复
47
+ // import { HISTORY_PLUGIN } from 'graphiql';
54
48
  const plugins = [explorer];
55
-
56
49
  const {
57
50
  endpoint,
58
51
  title,
@@ -61,7 +54,6 @@ export default function GraphQLPlayground({ ...rawProps }) {
61
54
  enableHistory,
62
55
  extraCodeSnippets,
63
56
  defaultQuery,
64
- extraHeaders,
65
57
  persistentQuery,
66
58
  ...rest
67
59
  } = newProps;
@@ -85,7 +77,7 @@ GraphQLPlayground.propTypes = {
85
77
  extraHeaders: PropTypes.any,
86
78
  };
87
79
 
88
- const Container = styled('div')`
80
+ const Container = styled(Box)`
89
81
  display: flex;
90
82
  flex-direction: row;
91
83
  flex: 1;