Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
graphql-modeler
Advanced tools
A GraphQL Voyager fork with schema editing capabilities, designed as a drop-in replacement for GraphQL Voyager.
A few notes: this is a work in progress and perhaps will never be finished or maintained (the fork is used in an internal project). There are some changes that you may not be OK with (some bits of text changed, required React version is >=16.8 because of hooks, etc.).
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!
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
[object
or function: (query: string) => Promise
] - the server introspection response. If function
is provided GraphQL Voyager will pass introspection query as a first function parameter. Function should return Promise
which resolves to introspection response object.displayOptions
(optional)
displayOptions.skipRelay
[boolean
, default true
] - skip relay-related entitiesdisplayOptions.skipDeprecated
[boolean
, default true
] - skip deprecated fields and entities that contain only deprecated fields.displayOptions.rootType
[string
] - name of the type to be used as a rootdisplayOptions.sortByAlphabet
[boolean
, default false
] - sort fields on graph by alphabetdisplayOptions.showLeafFields
[boolean
, default true
] - show all scalars and enumsdisplayOptions.hideRoot
[boolean
, default false
] - hide the root typehideDocs
[boolean
, default false
] - hide the docs sidebarhideSettings
[boolean
, default false
] - hide settings panelworkerURI
[string
] (optional) - absolute or relative path to Voyager web worker. By default it will try to load it from voyager.worker.js
.loadWorker
[function: (path: string, relative: boolean) => Promise<Worker>
] (optional) - If provided GraphQL Voyager will use this function to load the worker. By default it will use the internal callback in utils/index.ts
init
functionThe signature of the init
function:
(hostElement: HTMLElement, options: object) => void
hostElement
- parent elementoptions
- is the JS object with properties of Voyager
componentYou can get GraphQL Voyager bundle from the following places:
dist
folder of the npm package graphql-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="https://cdn.jsdelivr.net/npm/react@16/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@16/umd/react-dom.production.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.css" />
<script src="https://cdn.jsdelivr.net/npm/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 or use workerURI
property to specify other path.
NOTE if you use it with create-react-app
, copy worker file to public
folder and use workerURI
property like this:
<Voyager
// ...
workerURI={process.env.PUBLIC_URL + '/voyager.worker.js'}
// ...
/>
Graphql Voyager has middleware for the next frameworks:
Middleware supports the following properties:
endpointUrl
[string
] - the GraphQL endpoint url.displayOptions
[object
] - same as hereheadersJS
[string
, default "{}"
] - object of headers serialized in string to be used on endpoint url{ Authorization: localStorage['Meteor.loginToken'] }
import express from 'express';
import { express as voyagerMiddleware } from 'graphql-voyager/middleware';
const app = express();
app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
app.listen(3001);
import hapi from 'hapi';
import { hapi as voyagerMiddleware } from 'graphql-voyager/middleware';
const server = new Hapi.Server({
port: 3001
});
const init = async () => {
await server.register({
plugin: voyagerMiddleware,
options: {
path: '/voyager',
endpointUrl: '/graphql'
}
});
await server.start();
};
init();
import hapi from 'hapi';
import { hapiLegacy as voyagerMiddleware } from 'graphql-voyager/middleware';
const server = new Hapi.Server();
server.connection({
port: 3001
});
server.register({
register: voyagerMiddleware,
options: {
path: '/voyager',
endpointUrl: '/graphql'
}
},() => server.start());
import Koa from 'koa';
import KoaRouter from 'koa-router';
import { koa as voyagerMiddleware } from 'graphql-voyager/middleware';
const app = new Koa();
const router = new KoaRouter();
router.all('/voyager', voyagerMiddleware({
endpointUrl: '/graphql'
}));
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3001);
This tool is inspired by graphql-visualizer project.
FAQs
GraphQL introspection viewer and modeler
The npm package graphql-modeler receives a total of 0 weekly downloads. As such, graphql-modeler popularity was classified as not popular.
We found that graphql-modeler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.