Skip to content

Commit 2bb34bb

Browse files
committed
fix: upgrades, schema viewer display & width adjustment
1 parent 9f83ef1 commit 2bb34bb

File tree

16 files changed

+170
-128
lines changed

16 files changed

+170
-128
lines changed

packages/graphql-playground-electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"find-up": "^2.1.0",
9393
"graphcool-styles": "0.2.7",
9494
"graphcool-ui": "^0.0.14",
95-
"graphql": "^15.0.0",
95+
"graphql": "^0.13.2",
9696
"graphql-config": "^2.2.2",
9797
"graphql-config-extension-graphcool": "^1.0.11",
9898
"graphql-config-extension-prisma": "^0.3.0",

packages/graphql-playground-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
"typescript": "3.8.3",
104104
"typescript-styled-plugin": "^0.11.0",
105105
"url-loader": "4.0.0",
106-
"webpack": "4.42.1",
107-
"webpack-dev-server": "3.10.3",
106+
"webpack": "4.44.1",
107+
"webpack-dev-server": "3.11.0",
108108
"webpack-manifest-plugin": "2.2.0",
109109
"why-did-you-update": "0.1.1"
110110
},
@@ -120,7 +120,7 @@
120120
"cryptiles": "4.1.2",
121121
"cuid": "^1.3.8",
122122
"graphiql": "^0.17.5",
123-
"graphql": "^15.0.0",
123+
"graphql": "^15.3.0",
124124
"immutable": "^4.0.0-rc.9",
125125
"isomorphic-fetch": "^2.2.1",
126126
"js-yaml": "^3.10.0",

packages/graphql-playground-react/src/components/GraphQLBinApp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class GraphQLBinApp extends React.Component<Props & ReduxProps, State> {
5353
}
5454
}
5555

56-
componentWillMount() {
56+
UNSAFE_componentWillMount() {
5757
if (this.props.match.params.id) {
5858
if (this.props.match.params.id === 'new') {
5959
return

packages/graphql-playground-react/src/components/Playground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
196196
setSubscriptionEndpoint(props.subscriptionEndpoint)
197197
}
198198

199-
componentWillMount() {
199+
UNSAFE_componentWillMount() {
200200
// init redux
201201
this.props.initState(getWorkspaceId(this.props), this.props.endpoint)
202202
this.props.setConfigString(this.props.configString)
@@ -212,7 +212,7 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
212212
this.mounted = true
213213
}
214214

215-
componentWillReceiveProps(nextProps: Props & ReduxProps) {
215+
UNSAFE_componentWillReceiveProps(nextProps: Props & ReduxProps) {
216216
if (this.props.createApolloLink !== nextProps.createApolloLink) {
217217
setLinkCreator(nextProps.createApolloLink)
218218
}

packages/graphql-playground-react/src/components/Playground/DocExplorer/GraphDocs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class GraphDocs extends React.Component<
6565
;(window as any).d = this
6666
}
6767

68-
componentWillReceiveProps(nextProps: SideTabContentProps & StateFromProps) {
68+
UNSAFE_componentWillReceiveProps(nextProps: SideTabContentProps & StateFromProps) {
6969
// If user use default column size % columnWidth
7070
// Make the column follow the clicks
7171
if (

packages/graphql-playground-react/src/components/Playground/ExplorerTabs/SideTabs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
toggleDocs,
99
changeKeyMove,
1010
setDocsVisible,
11+
changeWidthDocs
1112
} from '../../../state/docs/actions'
1213
import { GraphQLSchema } from 'graphql'
1314
import { getSessionDocs } from '../../../state/docs/selectors'
@@ -252,6 +253,7 @@ const mapDispatchToProps = dispatch =>
252253
toggleDocs,
253254
changeKeyMove,
254255
setDocsVisible,
256+
changeWidthDocs
255257
},
256258
dispatch,
257259
)
@@ -269,6 +271,7 @@ const ConnectedGraphDocs = connect<StateFromProps, DispatchFromProps, Props>(
269271
{ forwardRef: true },
270272
)(SideTabs)
271273

274+
// @ts-ignore
272275
ConnectedGraphDocs.Tab = SideTab
273276

274277
export default ConnectedGraphDocs

packages/graphql-playground-react/src/components/Playground/GraphQLEditor.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,11 @@ class GraphQLEditor extends React.PureComponent<Props & ReduxProps> {
270270
</EditorBar>
271271
</EditorWrapper>
272272
<SideTabs
273+
sessionId={this.props.sessionId}
274+
schema={this.props.schema}
273275
setActiveContentRef={this.setSideTabActiveContentRef}
274276
setWidth={this.setDocsWidth}
277+
maxWidth={10000}
275278
>
276279
<SideTab label="Docs" activeColor="green" tabWidth="49px">
277280
<GraphDocs
@@ -284,6 +287,7 @@ class GraphQLEditor extends React.PureComponent<Props & ReduxProps> {
284287
schema={this.props.schema}
285288
ref={this.setSchemaExplorerRef}
286289
sessionId={this.props.sessionId}
290+
setWidth={this.setDocsWidth}
287291
/>
288292
</SideTab>
289293
</SideTabs>

packages/graphql-playground-react/src/components/Playground/QueryEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class QueryEditor extends React.PureComponent<Props & ReduxProps, {}> {
207207
})
208208
}
209209

210-
componentWillReceiveProps(nextProps) {
210+
UNSAFE_componentWillReceiveProps(nextProps) {
211211
if (this.props.sessionId !== nextProps.sessionId) {
212212
this.closeCompletion()
213213
this.updateSessionScrollTop()

packages/graphql-playground-react/src/components/Playground/SchemaExplorer/SDLEditor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ class SDLEditor extends React.PureComponent<Props, { overflowY: boolean }> {
9898
}
9999
}
100100

101-
componentWillReceiveProps(nextProps) {
101+
UNSAFE_componentWillReceiveProps(nextProps) {
102102
if (this.props.sessionId !== nextProps.sessionId) {
103103
this.editor.scrollTo(0, 0)
104104
}
105105
}
106106

107107
componentWillUnmount() {
108-
this.editor.off('scroll')
109-
this.editor = null
108+
if(this.editor) {
109+
this.editor.off('scroll')
110+
this.editor = null
111+
}
110112
}
111113

112114
handleScroll = e => {

packages/graphql-playground-react/src/components/Playground/SchemaExplorer/SDLHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class SDLHeader extends React.Component<SDLHeaderProps, State> {
2222
}
2323
}
2424

25-
componentWillMount() {
25+
UNSAFE_componentWillMount() {
2626
document.addEventListener('mousedown', this.handleClick, false)
2727
}
2828

packages/graphql-playground-react/src/components/Playground/SchemaExplorer/SDLView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ interface DispatchFromProps {
4141
}
4242

4343
class SDLView extends React.Component<
44-
SideTabContentProps & StateFromProps & DispatchFromProps
44+
SideTabContentProps & StateFromProps
4545
> {
4646
ref
4747
constructor(props) {
4848
super(props)
4949
;(window as any).d = this
5050
}
51-
componentWillReceiveProps(nextProps: SideTabContentProps & StateFromProps) {
51+
UNSAFE_componentWillReceiveProps(nextProps: SideTabContentProps & StateFromProps) {
5252
// If user use default column size % columnWidth
5353
// Make the column follow the clicks
5454
if (!this.props.schema && nextProps.schema) {

packages/graphql-playground-react/src/components/Playground/TopBar/Polling.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SchemaPolling extends React.Component<Props, State> {
4545
)
4646
}
4747
}
48-
componentWillReceiveProps(nextProps: Props) {
48+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
4949
this.updatePolling(nextProps)
5050
}
5151

packages/graphql-playground-react/src/components/Playground/util/createSDL.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ function getTypeInstance(type) {
6161
}
6262
}
6363

64-
// Adds Line Breaks to Schema View
65-
function addLineBreaks(sdl: string, commentsDisabled: boolean = true) {
66-
const noNewLines = sdl.replace(/^\s*$(?:\r\n?|\n)/gm, '')
67-
// Line Break all Brackets
68-
const breakBrackets = noNewLines.replace(/^[}]/gm, '$&\r\n')
69-
// Line Break all Scalars
70-
const withLineBreaks = breakBrackets.replace(/^(?:scalar )\w+/gm, '$&\r\n')
71-
72-
if (commentsDisabled) {
73-
return withLineBreaks
74-
}
75-
// Special Line Breaking for Comments
76-
const withCommentLineBreaks = withLineBreaks.replace(
77-
/(?:\#[\w\'\s\r\n\*](.*)$)/gm,
78-
'$&\r',
79-
)
80-
return withCommentLineBreaks
81-
}
8264

8365
// Returns a prettified schema
8466
export function getSDL(
@@ -89,21 +71,18 @@ export function getSDL(
8971
const rawSdl = printSchema(schema, { commentDescriptions: true })
9072
if (commentsDisabled) {
9173
// Removes Comments but still has new lines
92-
const sdlWithNewLines = rawSdl.replace(/(\#[\w\'\s\r\n\*](.*)$)/gm, '')
9374
// Removes newlines left behind by Comments
94-
const sdlWithoutComments = prettify(sdlWithNewLines, {
75+
return prettify(rawSdl, {
9576
printWidth: 80,
9677
tabWidth: 2,
9778
useTabs: false,
9879
})
99-
return addLineBreaks(sdlWithoutComments, commentsDisabled)
10080
}
101-
const sdl = prettify(rawSdl, {
81+
return prettify(rawSdl, {
10282
printWidth: 80,
10383
tabWidth: 2,
10484
useTabs: false,
10585
})
106-
return addLineBreaks(sdl)
10786
}
10887
return ''
10988
}

packages/graphql-playground-react/src/components/PlaygroundWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class PlaygroundWrapper extends React.Component<
199199
return endpoint.replace(/^http/, 'ws')
200200
}
201201

202-
componentWillReceiveProps(nextProps: PlaygroundWrapperProps & ReduxProps) {
202+
UNSAFE_componentWillReceiveProps(nextProps: PlaygroundWrapperProps & ReduxProps) {
203203
// Reactive props (props that cause a state change upon being changed)
204204
if (
205205
nextProps.endpoint !== this.props.endpoint ||
@@ -256,7 +256,7 @@ class PlaygroundWrapper extends React.Component<
256256
return url
257257
}
258258

259-
componentWillMount() {
259+
UNSAFE_componentWillMount() {
260260
const platformToken = getParameterByName('platform-token')
261261
if (platformToken && platformToken.length > 0) {
262262
localStorage.setItem('platform-token', platformToken)

packages/graphql-playground-react/src/components/SettingsEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class SettingsEditorHOC extends React.Component<
7979
super(props)
8080
this.state = { value: props.value }
8181
}
82-
componentWillReceiveProps(nextProps) {
82+
UNSAFE_componentWillReceiveProps(nextProps) {
8383
if (nextProps.value !== this.props.value) {
8484
this.setState({ value: nextProps.value })
8585
}

0 commit comments

Comments
 (0)