Skip to content

Commit

Permalink
Added GraphPage
Browse files Browse the repository at this point in the history
  • Loading branch information
jooohhn committed Jan 26, 2018
1 parent 089f69d commit 6f1884f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
5 changes: 1 addition & 4 deletions app/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export default function Footer() {
<div className="Footer">
<div className="FooterButtonContainer">
<div className="FooterButton FooterButton--active">
<Link to="/login">Login</Link>
</div>
<div className="FooterButton">
<Link to="/home/content">Content</Link>
</div>
<div className="FooterButton">
Expand All @@ -19,7 +16,7 @@ export default function Footer() {
<Link to="/home/structure">Structure</Link>
</div>
<div className="FooterButton">
<Link to="/graph">Graph</Link>
<Link to="/home/graph">Graph</Link>
</div>
</div>
</div>
Expand Down
35 changes: 17 additions & 18 deletions app/containers/GraphPage.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
import React from 'react';
import { Voyager } from 'graphql-voyager/dist/voyager';
import { db } from 'falcon-core';
import path from 'path';
import os from 'os';

const serverInfo = {
database: path.join(os.homedir(), 'Desktop/demo.sqlite'),
client: 'sqlite'
};
type Props = {databasePath: string};

export default function GraphPage() {
export default function GraphPage(props: Props) {
return (
<Voyager
introspection={introspectionProvider}
workerURI="https://unpkg.com/voyager-worker-test@1.0.0/index.js"
/>
);
}

async function introspectionProvider(query) {
const serverSession = db.createServer(serverInfo);
const connection = await serverSession.createConnection(serverInfo.database);
await connection.connect(serverInfo);
async function introspectionProvider(query) {
const serverInfo = {
database: props.databasePath,
client: 'sqlite'
};
const serverSession = db.createServer(serverInfo);
const connection = await serverSession.createConnection(serverInfo.database);
await connection.connect(serverInfo);

await connection.startGraphQLServer();
await connection.startGraphQLServer();

return fetch(`http://localhost:${connection.getGraphQLServerPort()}/graphql`, {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
}).then(response => response.json());
return fetch(`http://localhost:${connection.getGraphQLServerPort()}/graphql`, {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query }),
}).then(response => response.json());
}
}
2 changes: 2 additions & 0 deletions app/containers/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Switch, Route } from 'react-router';
import ContentPage from './ContentPage';
import StructurePage from './StructurePage';
import QueryPage from './QueryPage';
import GraphPage from './GraphPage';
import Header from '../components/Header';
import Footer from '../components/Footer';
import Sidebar from '../components/Sidebar';
Expand Down Expand Up @@ -138,6 +139,7 @@ class HomePage extends Component<Props, State> {
<Route path="/home/content" render={() => <ContentPage table={this.state.selectedTable} />} />
<Route path="/home/structure" component={StructurePage} />
<Route path="/home/query" component={QueryPage} />
<Route path="/home/graph" render={() => <GraphPage databasePath={this.props.databasePath} />} />
</Switch>
<Footer />
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"license": "MIT",
"dependencies": {
"falcon-core": "git+ssh://git@github.com:jooohhn/falcon-core.git#graphql-implementation",
"falcon-core": "git+ssh://git@github.com:amilajack/falcon-core.git#graphql-implementation",
"electron-store": "^1.2.0"
}
}
5 changes: 0 additions & 5 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { Switch, Route } from 'react-router';
import App from './containers/App';
import HomePage from './containers/HomePage';
import LoginPage from './containers/LoginPage';
<<<<<<< HEAD
import QueryPage from './containers/QueryPage';
import GraphPage from './containers/GraphPage';
=======
>>>>>>> ContentPage, Content, and Grid are passed state.selectedTable

// Routes to be rendered in root.js
export default () => (
Expand Down
Binary file modified test/e2e/demo.sqlite
Binary file not shown.
Binary file modified test/e2e/temp.sqlite
Binary file not shown.

0 comments on commit 6f1884f

Please sign in to comment.