Skip to content

Commit

Permalink
fix crash when toggling expand columns then query substructures, twea…
Browse files Browse the repository at this point in the history
…ks (#20)

- add query path to window title
- remove extra <p> tag
- remove unused function
  • Loading branch information
marcello3d authored Dec 13, 2020
1 parent 6a21354 commit 86e6bab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "graphql-98",
"productName": "GraphQL ‘98",
"version": "0.2.1",
"version": "0.2.2",
"private": true,
"description": "A visual GraphQL data browser. Like a SQL GUI for GraphQL!",
"repository": {
Expand Down
15 changes: 9 additions & 6 deletions src/renderer/components/GraphQlTypeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ function getColumns(
const argFields = arg.typeRef.type.fields;
if (argFields.length > 0) {
const obj: Variables = {};
for (const argField of argFields) {
if (argField.name in row) {
obj[argField.name] = row[argField.name];
if (row) {
for (const argField of argFields) {
if (argField.name in row) {
obj[argField.name] = row[argField.name];
}
}
}
if (Object.keys(obj)) {
args[arg.name] = obj;
return true;
}
} else {
if (arg.name in row) {
if (row && arg.name in row) {
args[arg.name] = row[arg.name];
return true;
}
Expand Down Expand Up @@ -157,13 +159,13 @@ export function GraphQlTypeView({
getColumns(
url,
firstNode.children,
expandColumns,
substructures && expandColumns,
structure.typeQueries,
firstNode.typeRef.type,
),
[
url,
expandColumns,
substructures && expandColumns,
firstNode.children,
firstNode.typeRef.type,
structure.typeQueries,
Expand All @@ -187,6 +189,7 @@ export function GraphQlTypeView({
type="checkbox"
checked={expandColumns}
onChange={setExpandColumns}
disabled={!substructures}
id="expand_substructures"
/>{' '}
<label htmlFor="expand_substructures">Expand columns</label>
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/components/Window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { version } from '../../../package.json';
const minimize = window.ElectronMainApi.minimize;
const maximize = window.ElectronMainApi.maximize;
const unmaximize = window.ElectronMainApi.unmaximize;
const preventDefault = (event: React.MouseEvent) => {
event.stopPropagation();
event.preventDefault();
};

const close = (event: React.MouseEvent) => {
event.stopPropagation();
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/pages/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { githubUrl } from '../components/about';
import { Window } from '../components/Window';
import { GraphQlWrapper } from '../components/GraphQlWrapper';

export function GraphQlPage({ url }: { url: string }) {
export function GraphQlPage({ url, path }: { url: string; path?: string }) {
return (
<Window title={`Graph QL ‘98: ${url}`}>
<Window title={`Graph QL ‘98${url}${path ? ` : ${path}` : ''}`}>
<GraphQlWrapper url={url} />
</Window>
);
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { GraphQlPage } from './graphql';

export function IndexPage(_: RouteComponentProps) {
const [url] = useQueryParam('url', StringParam);
const [path] = useQueryParam('path', StringParam);

if (url) {
return <GraphQlPage key={url} url={url} />;
return <GraphQlPage key={url} url={url} path={path || undefined} />;
}
return <WelcomePage />;
}
4 changes: 1 addition & 3 deletions src/renderer/pages/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export function WelcomePage(_: RouteComponentProps) {
</p>

<h2>Open URL</h2>
<p>
<UrlChooser />
</p>
<UrlChooser />
<h2>Quick start</h2>
<p>
Here are some public GraphQL endpoints to try courtesy of{' '}
Expand Down

0 comments on commit 86e6bab

Please sign in to comment.