Bunjil


bunjil.js.org | Getting Started
Bunjil is a public facing GraphQL server.
It comes with Policy Based authorization, and hook for your own authentication (Passport.js, Auth0, database).
It’s purpose is to allow the stitching of one or more private GraphQL Schemas into a public one.
Getting Started
Documentation coming real soon.
Roadmap
Getting Started
yarn add bunjil
npm install bunjil
import { Bunjil, Policy, PolicyCondition, PolicyEffect } from "bunjil";
const typeDefs: string = `
type User {
id: ID
name: String
password: String
posts(limit: Int): [Post]
}
type Post {
id: ID
title: String
views: Int
author: User
}
type Query {
author(id: ID): User
topPosts(limit: Int): [Post]
}
`;
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
const policies: Policy[] = [
{
id: "public:read-all",
resources: ["Query::topPosts", "Post::*", "User::*"],
actions: ["query"],
effect: PolicyEffect.Allow,
roles: ["*"],
},
{
id: "deny:user::password",
resources: ["User::password"],
actions: ["query"],
effect: PolicyEffect.Deny,
roles: ["*"],
},
];
const bunjil: Bunjil = new Bunjil({
server: {
port: 3000,
tracing: true,
cacheControl: true,
},
playgroundOptions: {
enabled: false,
},
endpoints: {
graphQL: "/graphql",
subscriptions: "/graphql/subscriptions",
playground: "/playground",
},
policies,
});
bunjil.addSchema({ schemas: [schema] });
await bunjil.start();
Usage
Running the tests
Use yarn test
or npm run test
.
Tests are written with ava
, and we would strongly like tests with any new functionality.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
License

This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments