bs-apollo-server-express
![CircleCI](https://circleci.com/gh/rricard/bs-apollo-server-express.svg?style=svg)
BuckleScript binding for apollo-server-express.
Installation
This package is just a binding and you will need to import the original apollo-server-express package as well.
npm install --save apollo-server-express bs-apollo-server-express
# or
yarn add apollo-server-express bs-apollo-server-express
As always, you will need to indicate to BuckleScript that the binding is available.
bsconfig.json
{
...
"bs-dependencies": [
"bs-apollo-server-express"
]
}
Usage
You can start a GraphQL server using bs-graphql, bs-express and this binding:
let app = Express.App.make ();
let schema = GraphQL.Utilities.buildSchema "type Query { hello: String }";
let rootValue = {"hello": fun () => "world"};
let middleware = ApolloServerExpress.createGraphQLExpressMiddleware schema ::rootValue;
external bodyParserJson : unit => Express.Middleware.t = "json" [@@bs.module "body-parser"];
Express.App.use app (bodyParserJson ());
Express.App.useOnPath app middleware path::"/graphql";
Express.App.listen app port::8080;
Now you can make GraphQL queries to http://localhost:8080
.
Contribute
git clone git@github.com:rricard/bs-apollo-server-express.git
cd bs-apollo-server-express
yarn
yarn build
Then, you can run two watchers, one for compiling, one for testing:
yarn watch
yarn test -- --watch