@arcblock/graphql-playground 2.1.57 → 2.1.58

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/lib/index.js CHANGED
@@ -25,9 +25,11 @@ var _snippets = _interopRequireDefault(require("graphiql-code-exporter/lib/snipp
25
25
 
26
26
  var _graphql = require("graphql");
27
27
 
28
+ var _react2 = require("@graphiql/react");
29
+
28
30
  var _reactRouterDom = require("react-router-dom");
29
31
 
30
- require("./graphiql.css");
32
+ require("graphiql/graphiql.css");
31
33
 
32
34
  require("graphiql-code-exporter/CodeExporter.css");
33
35
 
@@ -53,6 +55,26 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
53
55
 
54
56
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
55
57
 
58
+ function HistoryToggleButton() {
59
+ const {
60
+ toggle
61
+ } = (0, _react2.useHistoryContext)();
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
63
+ onClick: toggle,
64
+ label: "History",
65
+ title: "Show History"
66
+ });
67
+ }
68
+
69
+ function PrettifyButton() {
70
+ const prettify = (0, _react2.usePrettifyEditors)();
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
72
+ onClick: prettify,
73
+ label: "Prettify",
74
+ title: "Prettify Query (Shift-Ctrl-P)"
75
+ });
76
+ }
77
+
56
78
  function GraphQLPlayground(props) {
57
79
  const newProps = (0, _Util.mergeProps)(props, GraphQLPlayground, ['style', 'persistentQuery', 'enableQueryComposer', 'enableCodeExporter', 'enableHistory']);
58
80
  const history = (0, _reactRouterDom.useHistory)();
@@ -247,15 +269,7 @@ function GraphQLPlayground(props) {
247
269
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Logo, {
248
270
  children: title
249
271
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_graphiql.default.Toolbar, {
250
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
251
- onClick: () => graphiql.current.handlePrettifyQuery(),
252
- label: "Prettify",
253
- title: "Prettify Query (Shift-Ctrl-P)"
254
- }), enableHistory && /*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
255
- onClick: () => graphiql.current.handleToggleHistory(),
256
- label: "History",
257
- title: "Show History"
258
- }), enableQueryComposer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
272
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PrettifyButton, {}), enableHistory && /*#__PURE__*/(0, _jsxRuntime.jsx)(HistoryToggleButton, {}), enableQueryComposer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_graphiql.default.Button, {
259
273
  onClick: onToggleExplorer,
260
274
  label: "Query Composer",
261
275
  title: "Toggle Query Composer"
@@ -303,4 +317,4 @@ GraphQLPlayground.defaultProps = {
303
317
  const Container = _styledComponents.default.div.withConfig({
304
318
  displayName: "src__Container",
305
319
  componentId: "sc-rvsulm-0"
306
- })(["display:flex;flex-direction:row;flex:1;overflow:hidden;height:100%;position:relative;@media (max-width:", "px){margin-top:30px;}> .historyPaneWrap{z-index:8 !important;width:320px !important;box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");overflow-y:scroll;}.doc-explorer-title-bar,.history-title-bar{height:45px;line-height:45px;padding:0px 8px;display:flex;align-items:center;justify-content:space-between;}.doc-explorer-title-bar{padding:0px 32px;}.doc-explorer-title,.history-title{font-size:14px;font-weight:900;letter-spacing:2px;color:", ";text-transform:uppercase;text-align:left !important;}.doc-explorer-contents,.history-contents{top:45px !important;background-color:", " !important;border-top:1px solid #e3e3e3 !important;}.history-contents{color:", ";p{border-bottom:1px solid #e3e3e3;}}.docExplorerHide{color:", ";padding:0;cursor:pointer;margin:-7px -8px -6px -12px;opacity:0.75;font-size:18px;}.toolbar-button{cursor:pointer;}.graphiql-container{.title{color:", ";}.topBar{background-image:none;height:45px;border-bottom-width:0;}.docExplorerShow{background:", ";border:none;font-size:14px;color:", ";text-transform:uppercase;&::before{border-color:", ";}}.docExplorerWrap{position:absolute !important;height:100%;top:0;right:0;background-color:", ";box-shadow:-5px 16px 10px 0 rgba(0,0,0,", ");z-index:3;}.historyPaneWrap{width:320px !important;background-color:", ";box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");}.docExplorerWrap{.doc-explorer{background-color:", ";}.doc-explorer-contents{padding:32px;}}.search-box{margin-bottom:20px;border-bottom:none;input{height:30px;border-radius:15px;border:solid 1px ", ";padding:6px 24px 8px 30px;}.search-box-clear{right:10px;}&::before{left:10px;}}.variable-editor-title{background:", ";border:none;height:40px;padding-left:20px;&::before{border-left:2px solid ", ";border-top:2px solid ", ";content:'';display:inline-block;height:9px;margin:0 5px 1px 0;position:relative;-webkit-transform:rotate(-135deg);transform:rotate(-135deg);width:9px;}}.resultWrap{border-left:none;.CodeMirror-gutters{opacity:0.5;}.CodeMirror-gutter.CodeMirror-foldgutter{box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");}}.CodeMirror,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-foldgutter{background:", ";}.variable-editor{.CodeMirror{background:white;}}.CodeMirror-gutters{border-right-width:0;}}.graphiql-exporter-container{width:auto;.historyPaneWrap{position:absolute !important;height:100%;top:0;right:0;background-color:", ";box-shadow:-5px 16px 10px 0 rgba(0,0,0,", ");z-index:3;.history-contents{padding-top:12px;.toolbar-button{margin-top:-24px !important;}}}}"], props => props.theme.breakpoints.values.md, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.typography.color.gray, props => props.theme.palette.background.default, props => props.theme.typography.color.main, props => props.theme.typography.color.main, props => props.theme.typography.color.main, props => props.theme.palette.background.default, props => props.theme.typography.color.main, props => props.theme.typography.color.gray, props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.palette.background.default, props => props.theme.typography.color.main, props => props.theme.palette.background.default, props => props.theme.typography.color.gray, props => props.theme.typography.color.gray, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.palette.background.default, props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5);
320
+ })(["display:flex;flex-direction:row;flex:1;overflow:hidden;height:100%;position:relative;@media (max-width:", "px){margin-top:30px;}> .historyPaneWrap{z-index:8 !important;width:320px !important;box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");overflow-y:scroll;}.doc-explorer-title-bar,.history-title-bar{height:45px;line-height:45px;padding:0px 8px;display:flex;align-items:center;justify-content:space-between;}.doc-explorer-title-bar{padding:0px 32px;}.doc-explorer-title,.history-title{font-size:14px;font-weight:900;letter-spacing:2px;color:", ";text-transform:uppercase;text-align:left !important;}.doc-explorer-contents,.history-contents{top:45px !important;background-color:", " !important;border-top:1px solid #e3e3e3 !important;}.history-contents{color:", ";p{border-bottom:1px solid #e3e3e3;}}.docExplorerHide{color:", ";padding:0;cursor:pointer;margin:-7px -8px -6px -12px;opacity:0.75;font-size:18px;}.toolbar-button{cursor:pointer;}.graphiql-container{.title{color:", ";}.topBar{background-image:none;height:45px;border-bottom-width:0;}.docExplorerShow{background:", ";border:none;font-size:14px;color:", ";text-transform:uppercase;&::before{border-color:", ";}}.historyPaneWrap{width:320px !important;background-color:", ";box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");}.search-box{margin-bottom:20px;border-bottom:none;input{height:30px;border-radius:15px;border:solid 1px ", ";padding:6px 24px 8px 30px;}.search-box-clear{right:10px;}&::before{left:10px;}}.variable-editor-title{background:", ";border:none;height:40px;padding-left:20px;&::before{border-left:2px solid ", ";border-top:2px solid ", ";content:'';display:inline-block;height:9px;margin:0 5px 1px 0;position:relative;-webkit-transform:rotate(-135deg);transform:rotate(-135deg);width:9px;}}.resultWrap{border-left:none;.CodeMirror-gutters{opacity:0.5;}.CodeMirror-gutter.CodeMirror-foldgutter{box-shadow:5px 16px 10px 0 rgba(0,0,0,", ");}}.CodeMirror,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-foldgutter{background:", ";}.variable-editor{.CodeMirror{background:white;}}.CodeMirror-gutters{border-right-width:0;}}.graphiql-exporter-container{width:auto;.historyPaneWrap{position:absolute !important;height:100%;top:0;right:0;background-color:", ";box-shadow:-5px 16px 10px 0 rgba(0,0,0,", ");z-index:3;.history-contents{padding-top:12px;.toolbar-button{margin-top:-24px !important;}}}}"], props => props.theme.breakpoints.values.md, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.typography.color.gray, props => props.theme.palette.background.default, props => props.theme.typography.color.main, props => props.theme.typography.color.main, props => props.theme.typography.color.main, props => props.theme.palette.background.default, props => props.theme.typography.color.main, props => props.theme.typography.color.gray, props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.typography.color.main, props => props.theme.palette.background.default, props => props.theme.typography.color.gray, props => props.theme.typography.color.gray, props => props.theme.mode === 'light' ? 0.05 : 0.5, props => props.theme.palette.background.default, props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/graphql-playground",
3
- "version": "2.1.57",
3
+ "version": "2.1.58",
4
4
  "description": "A React Component to interact with GraphQL APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -33,13 +33,13 @@
33
33
  "url": "https://github.com/ArcBlock/ux/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@arcblock/ux": "^2.1.57",
36
+ "@arcblock/ux": "^2.1.58",
37
37
  "axios": "^0.21.2",
38
38
  "core-js": "^3.6.4",
39
- "graphiql": "^0.13.2",
40
- "graphiql-code-exporter": "^2.0.5",
41
- "graphiql-explorer": "^0.4.3",
42
- "graphql": "^14.6.0",
39
+ "graphiql": "^1.9.11",
40
+ "graphiql-code-exporter": "^3.0.3",
41
+ "graphiql-explorer": "^0.9.0",
42
+ "graphql": "^16.5.0",
43
43
  "react-load-script": "^0.0.6",
44
44
  "react-router-dom": "^5.1.2",
45
45
  "styled-components": "^5.0.0"
@@ -59,5 +59,5 @@
59
59
  "eslint-plugin-react-hooks": "^4.2.0",
60
60
  "jest": "^24.1.0"
61
61
  },
62
- "gitHead": "3bf280fd6c092c0cf1649f42f65fc052b7598bbf"
62
+ "gitHead": "30964d1c8f22b57ed04288d329d488593568ac34"
63
63
  }
package/src/index.js CHANGED
@@ -11,15 +11,27 @@ import QueryComposer from 'graphiql-explorer';
11
11
  import CodeExporter from 'graphiql-code-exporter';
12
12
  import CodeExporterSnippets from 'graphiql-code-exporter/lib/snippets';
13
13
  import { buildClientSchema, getIntrospectionQuery, parse } from 'graphql';
14
+ import { useHistoryContext, usePrettifyEditors } from '@graphiql/react';
15
+
14
16
  import { useHistory } from 'react-router-dom';
17
+ import 'graphiql/graphiql.css';
15
18
 
16
- import './graphiql.css';
17
19
  import 'graphiql-code-exporter/CodeExporter.css';
18
20
  import 'codemirror/theme/neo.css';
19
21
 
20
22
  import { mergeProps, parseQuery, stringifyQuery } from '@arcblock/ux/lib/Util';
21
23
  import { graphQLFetcher } from './util';
22
24
 
25
+ function HistoryToggleButton() {
26
+ const { toggle } = useHistoryContext();
27
+ return <GraphiQL.Button onClick={toggle} label="History" title="Show History" />;
28
+ }
29
+
30
+ function PrettifyButton() {
31
+ const prettify = usePrettifyEditors();
32
+ return <GraphiQL.Button onClick={prettify} label="Prettify" title="Prettify Query (Shift-Ctrl-P)" />;
33
+ }
34
+
23
35
  export default function GraphQLPlayground(props) {
24
36
  const newProps = mergeProps(props, GraphQLPlayground, [
25
37
  'style',
@@ -214,18 +226,8 @@ export default function GraphQLPlayground(props) {
214
226
  <GraphiQL ref={graphiql} fetcher={fetcher} schema={schema} query={query} onEditQuery={onEditQuery}>
215
227
  <GraphiQL.Logo>{title}</GraphiQL.Logo>
216
228
  <GraphiQL.Toolbar>
217
- <GraphiQL.Button
218
- onClick={() => graphiql.current.handlePrettifyQuery()}
219
- label="Prettify"
220
- title="Prettify Query (Shift-Ctrl-P)"
221
- />
222
- {enableHistory && (
223
- <GraphiQL.Button
224
- onClick={() => graphiql.current.handleToggleHistory()}
225
- label="History"
226
- title="Show History"
227
- />
228
- )}
229
+ <PrettifyButton />
230
+ {enableHistory && <HistoryToggleButton />}
229
231
  {enableQueryComposer && (
230
232
  <GraphiQL.Button onClick={onToggleExplorer} label="Query Composer" title="Toggle Query Composer" />
231
233
  )}
@@ -364,31 +366,12 @@ const Container = styled.div`
364
366
  }
365
367
  }
366
368
 
367
- .docExplorerWrap {
368
- position: absolute !important;
369
- height: 100%;
370
- top: 0;
371
- right: 0;
372
- background-color: ${(props) => props.theme.palette.background.default};
373
- box-shadow: -5px 16px 10px 0 rgba(0, 0, 0, ${(props) => (props.theme.mode === 'light' ? 0.05 : 0.5)});
374
- z-index: 3;
375
- }
376
-
377
369
  .historyPaneWrap {
378
370
  width: 320px !important;
379
371
  background-color: ${(props) => props.theme.palette.background.default};
380
372
  box-shadow: 5px 16px 10px 0 rgba(0, 0, 0, ${(props) => (props.theme.mode === 'light' ? 0.05 : 0.5)});
381
373
  }
382
374
 
383
- .docExplorerWrap {
384
- .doc-explorer {
385
- background-color: ${(props) => props.theme.palette.background.default};
386
- }
387
- .doc-explorer-contents {
388
- padding: 32px;
389
- }
390
- }
391
-
392
375
  .search-box {
393
376
  margin-bottom: 20px;
394
377
  border-bottom: none;