2.1.2 • Published 5 years ago
biothings-explorer-graphql v2.1.2
Biothings Explorer GraphQL
GraphQL app for BioThings Explorer
Example Usage
See example/ for a complete usage example.
Making Queries
Visit the wiki page on Forming and Executing Queries for more info.
Integrate into existing Express server (recommended)
Install
npm install biothings-explorer-graphql graphqlnpm install express(ignore this step if express is already installed)
Integrate Into Server
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);Run as a Vanilla Standalone Server
Install
git clone https://github.com/ericz1803/biothings_explorer_graphql.gitcd biothings_explorer_graphql/npm installnpm install graphql express
Start Server
npm start
Run Tests
npm run test