GraphQL app for BioThings Explorer
See example/
for a complete usage example.
Visit the wiki page on Forming and Executing Queries for more info.
npm install biothings-explorer-graphql graphql
npm install express
(ignore this step if express is already installed)
Add the following lines to your express server. (Wrap everything in an async
function if top level await
is not available.)
By default, it will be served on the /graphql
path.
const getServer = require("biothings-explorer-graphql");
const server = await getServer();
server.applyMiddleware({ app });
To serve it on a different path, use
server.applyMiddleware({ app, path: "/your-path" });
To pass other parameters to ApolloServer, pass a config object to the getServer
function. (Refer to documentation for other options)
See example/
for an example using more advanced options.
const config = {
//enable introspection and playground in production
//(these options will be injected into the ApolloServer constructor after the `typeDefs` and `resolvers` are automatically passed in)
introspection: true,
playground: true,
};
const server = getServer(config);
git clone https://github.com/ericz1803/biothings_explorer_graphql.git
cd biothings_explorer_graphql/
npm install
npm install graphql express
npm start
npm run test