Skip to content

Commit 6374003

Browse files
committed
reenable header injection
1 parent 5c79d70 commit 6374003

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export interface Props {
8383
configPath?: string
8484
createApolloLink?: (session: Session) => ApolloLink
8585
workspaceName?: string
86-
shouldInjectHeaders: boolean
8786
}
8887

8988
export interface ReduxProps {
@@ -152,9 +151,7 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
152151
// init redux
153152
this.props.initState(getWorkspaceId(this.props), this.props.endpoint)
154153
this.props.setConfigString(this.props.configString)
155-
if (this.props.shouldInjectHeaders) {
156-
this.props.injectHeaders(this.props.headers, this.props.endpoint)
157-
}
154+
this.props.injectHeaders(this.props.headers, this.props.endpoint)
158155
}
159156

160157
componentDidMount() {
@@ -193,10 +190,7 @@ export class Playground extends React.PureComponent<Props & ReduxProps, State> {
193190
if (this.props.subscriptionEndpoint !== nextProps.subscriptionEndpoint) {
194191
setSubscriptionEndpoint(nextProps.subscriptionEndpoint)
195192
}
196-
if (
197-
nextProps.headers !== this.props.headers &&
198-
this.props.shouldInjectHeaders
199-
) {
193+
if (nextProps.headers !== this.props.headers) {
200194
this.props.injectHeaders(nextProps.headers, nextProps.endpoint)
201195
}
202196
if (nextProps.configString !== this.props.configString) {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export interface State {
6464
activeProjectName?: string
6565
activeEnv?: string
6666
headers?: any
67-
shouldInjectHeaders: boolean
6867
}
6968

7069
class PlaygroundWrapper extends React.Component<
@@ -119,7 +118,6 @@ class PlaygroundWrapper extends React.Component<
119118
activeEnv,
120119
activeProjectName: projectName,
121120
headers,
122-
shouldInjectHeaders: false,
123121
}
124122
}
125123

@@ -131,7 +129,6 @@ class PlaygroundWrapper extends React.Component<
131129
try {
132130
const headers = getParameterByName('headers', endpoint)
133131
if (headers) {
134-
this.setState({ shouldInjectHeaders: true })
135132
return { headers: JSON.parse(headers), endpoint: splitted[0] }
136133
}
137134
} catch (e) {
@@ -325,7 +322,6 @@ class PlaygroundWrapper extends React.Component<
325322
headers={this.state.headers}
326323
configPath={this.props.configPath}
327324
workspaceName={this.state.activeProjectName}
328-
shouldInjectHeaders={this.state.shouldInjectHeaders}
329325
/>
330326
</App>
331327
</OldThemeProvider>

packages/graphql-playground-react/src/localDevIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const config = {
5454
url: 'https://eu1.prisma.sh/lol/asdf/dev',
5555
headers: {
5656
Authorization:
57-
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InNlcnZpY2UiOiJwcmlzbWEtYWlyYm5iLWV4YW1wbGVAZGV2Iiwicm9sZXMiOlsiYWRtaW4iXX0sImlhdCI6MTUyMjY4NDkzNiwiZXhwIjoxNTIzMjg5NzM2fQ.1wnkIJrAplDOznjEzLj8sQERL6dcAM0zjqxOGQBXGn0',
57+
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InNlcnZpY2UiOiJhc2RmQGRldiIsInJvbGVzIjpbImFkbWluIl19LCJpYXQiOjE1MjM1MTg3NTYsImV4cCI6MTUyNDEyMzU1Nn0.fzKhXa1JpN9M1UGTbS6p2KMUWDrKLxYD3i3a9eVfOQQ',
5858
},
5959
},
6060
},

packages/graphql-playground-react/src/state/sessions/reducers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ const reducer = handleActions(
278278
})
279279
},
280280
SET_SCROLL_TOP: (state, { payload: { sessionId, scrollTop } }) => {
281-
return state.setIn(['sessions', sessionId, 'scrollTop'], scrollTop)
281+
if (state.sessions.get(sessionId)) {
282+
return state.setIn(['sessions', sessionId, 'scrollTop'], scrollTop)
283+
}
284+
return state
282285
},
283286
SCHEMA_FETCHING_SUCCESS: (state, { payload }) => {
284287
const newSessions = state

0 commit comments

Comments
 (0)