Skip to content

Commit 39a1110

Browse files
committed
fix(electron): endpoint injection
1 parent d3b403d commit 39a1110

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/graphql-playground-electron/src/renderer/components/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ cd ${folderPath}; graphql playground`)
327327

328328
console.log('setting', { state })
329329

330-
this.serializeWorkspace(state)
330+
if (endpoint) {
331+
this.serializeWorkspace(state)
332+
}
331333

332334
this.setState(state)
333335
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ class PlaygroundWrapper extends React.Component<
180180
) {
181181
const configIsYaml = this.isConfigYaml(nextProps.configString)
182182
this.setState({ configIsYaml })
183+
if (nextProps.config) {
184+
const activeEnv = this.getInitialActiveEnv(nextProps.config)
185+
const endpoints = getActiveEndpoints(
186+
nextProps.config,
187+
activeEnv.activeEnv!,
188+
this.state.activeProjectName,
189+
)
190+
const endpoint = endpoints.endpoint
191+
const subscriptionEndpoint = endpoints.subscriptionEndpoint
192+
const headers = endpoints.headers
193+
this.setState({
194+
endpoint,
195+
subscriptionEndpoint,
196+
headers,
197+
activeEnv: activeEnv.activeEnv,
198+
})
199+
}
183200
}
184201
}
185202

0 commit comments

Comments
 (0)