GraphQL project boilerplate based on Koa.js, TypeScript and Apollo Server
We're using the official apollo-server-koa.
-
Git commit message validation with commitlint and husky
-
Support Modularizing Schema and Resolver by merge-graphql-schemas
-
Auto generates code out of your GraphQL schema by graphql-code-generator
-
Support automatically restarting the node application then code changes by nodemon
To illustrate the result of this boilerplate, we are creating an online E-commerce App, which has the following entities: Product
, User
, Order
. The schema definitions are like this:
type Product {
productId: ID!
name: String!
img: String!
price: Int!
}
type User {
userId: ID!
name: String!
age: Int!
orders: [Order]
}
type Order {
orderId: ID!
product: Product!
user: User!
# the number of the product
num: Int!
# timestamp when order created
createAt: Int
}
Following is Query
and Mutation
:
Query {
productList: [Product]!
productDetail: Produce
me: User
}
Mutation {
login(name: String!, password: String)
buy(productId: ID!, num: Int!): Order
}