Skip to content

Commit

Permalink
feat: reintroduce graphql-voyager, strip old explorer code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Redington committed Sep 13, 2021
1 parent 4ae9152 commit a7e6185
Show file tree
Hide file tree
Showing 32 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
explorer-old
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package.json
src/explorer
explorer-old
yarn.lock
.next
public
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"migrate": "migrate-mongo up",
"generate": "node -r dotenv/config ./src/api/db/manage/generate/index.js --confirm",
"areas": "node -r dotenv/config ./src/api/db/manage/areaToDatabase/index.js",
"prepare": "husky install",
"prepare": "husky install && cp ./node_modules/graphql-voyager/dist/voyager.worker.js ./public",
"codegen": "graphql-codegen --config codegen.yml"
},
"repository": {
Expand Down
36 changes: 36 additions & 0 deletions src/pages/explorer/voyager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import dynamic from 'next/dynamic';
import Head from 'next/head';
import PageLayout from '../../components/PageLayout';
import Container from '../../components/Container';
import config from '../../config';
import 'graphql-voyager/dist/voyager.css';

const VoyagerComponent = dynamic(
() => import('graphql-voyager').then((mod) => mod.Voyager),
{ ssr: false }
);

function introspectionProvider(query) {
return fetch('/api', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: query }),
}).then((response) => response.json());
}

const Voyager = () => (
<PageLayout layoutMode="blog">
<Head>
<title>{config.getTitle('Schema Visualisation')}</title>
</Head>

<Container>
<VoyagerComponent
introspection={introspectionProvider}
workerURI={'/voyager.worker.js'}
/>
</Container>
</PageLayout>
);

export default Voyager;

0 comments on commit a7e6185

Please sign in to comment.