Represent any GraphQL API as an interactive graph. It's time to finally see the graph behind GraphQL. You can also explore number of public GraphQL APIs from our list.
With graphql-voyager you can visually explore your GraphQL API as an interactive graph. This is a great tool when designing or discussing your data model. It includes multiple example GraphQL schemas and also allows you to connect it to your own GraphQL endpoint. What are you waiting for, explore your API!
- Quick navigation on graph
- Left panel which provides more detailed information about every type
- "Skip Relay" option that simplifies graph by removing Relay wrapper classes
- Ability to choose any type to be a root of the graph
- Major refactoring
- Publish as a library (issue 1)
- Tests + CI + CD
- Try to optimize graph auto-layout
- < place for your ideas >
GraphQL Voyager exports Voyager React component and helper init function. If used without
module system it is exported as GraphQLVoyager global variable.
Voyager component accepts the following properties:
introspection[objector function:(query: string) => Promise] - the server introspection response. Iffunctionis provided GraphQL Voyager will pass introspection query as a first function parameter. Function should returnPromisewhich resolves to introspection response object.displayOptionsdisplayOptions.skipRelay[boolean, defaulttrue] - skip relay-related entitiesdisplayOptions.rootType[string] - name of the type to be used as a rootdisplayOptions.sortByAlphabet[boolean, defaultfalse] - sort fields on graph by alphabet
The signature of the init function:
(hostElement: HTMLElement, options: object) => voidhostElement- parent elementoptions- is the JS object with properties ofVoyagercomponent
You can get GraphQL Voyager bundle from the following places:
- our GitHub Pages-based CDN
- some exact version - https://apis.guru/graphql-voyager/releases/v1.0.0-rc.0/voyager.min.js
- latest 1.x version - https://apis.guru/graphql-voyager/releases/v1.x/voyager.min.js
- download zip from releases page and use files from
distfolder - from
distfolder of the npm packagegraphql-voyager
Important: for the latest two options make sure to copy voyager.worker.js to the same
folder as voyager.min.js.
The HTML with minimal setup (see the full example)
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>
<script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>
<link rel="stylesheet" href="./node_modules/graphql-voyager/dist/voyager.css" />
<script src="./node_modules/graphql-voyager/dist/voyager.min.js"></script>
</head>
<body>
<div id="voyager">Loading...</div>
<script>
function introspectionProvider(introspectionQuery) {
// ... do a call to server using introspectionQuery provided
// or just return pre-fetched introspection
}
// Render <Voyager />
GraphQLVoyager.init(document.getElementById('voyager'), {
introspection: introspectionProvider
})
</script>
</body>
</html>You can install lib using npm or yarn:
npm i --save graphql-voyager
yarn add graphql-voyager
And then use it:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {Voyager} from 'graphql-voyager';
import fetch from 'isomorphic-fetch';
function introspectionProvider(query) {
return fetch(window.location.origin + '/graphql', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({query: query}),
}).then(response => response.json());
}
ReactDOM.render(<Voyager introspection={introspectionProvider} />, document.getElementById('voyager'));Build for the web with webpack (example) or browserify
Important: make sure to copy voyager.worker.js from node_modules/graphql-voyager/dist to the same folder as your main bundle.
This tool is inspired by graphql-visualizer project.

