Rapid prototyping of GraphQL backend applications using Node.js.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to install the software and how to install them
git clone https://github.com/bermanboris/boman-boilerplate
A step by step series of examples that tell you have to get a development env running
Installation using Yarn:
yarn install
or NPM:
npm install
You can start the server using:
yarn start
or using NPM:
npm start
You can find "GraphiQL" UI on the http://localhost:5050/graphiql
Get all users:
{
getUsers {
name
age
}
}
or add new user:
mutation {
addUser(name: "Michael", age: 18) {
name
age
}
}
You can add custom controller by creating JS file inside "controllers" directory. For example, let's create "UserController".
/controllers/UserController.js
import { RootController } from 'boman';
@RootController
class UserController {
hello() {
return 'hi';
}
}
export default UserController;
When you create new class controller, you need to decorate it with "RootController"
decorator from "boman" npm package. This way you get access to "express" request
object (this.req
) in your controller, and the db models (this.models
).
Controller automatically passed to all your resolvers context, and you can use them immediately without doing extra work.
Let's try using UserController we've just created:
/graphql/resolvers.js
export default {
Query: {
sayHello(parent, args, { UserController }) {
return UserController.hello();
}
}
};
Like you can see, "it just works" out of the box! Don't forget to add GraphQL type to the type.gql file. Let's add it:
/graphql/type.gql
type Query {
sayHello: String!
}
And we're done!
- Boman - Node.js GraphQL Framework
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Boris Berman - Creator - Boris Berman
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone who's code was used
- Inspiration
- etc