Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunxiuguo/koa-graphql-template
This is a koa Graphql server template build with typescript, use type-graphql and typegoose
https://github.com/sunxiuguo/koa-graphql-template
graphql koa-graphql-template koa2 mongodb mongoose nodejs type-graphql typegoose typescript
Last synced: 29 days ago
JSON representation
This is a koa Graphql server template build with typescript, use type-graphql and typegoose
- Host: GitHub
- URL: https://github.com/sunxiuguo/koa-graphql-template
- Owner: sunxiuguo
- License: mit
- Created: 2020-03-26T03:29:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T22:26:47.000Z (almost 2 years ago)
- Last Synced: 2023-03-04T10:52:51.705Z (almost 2 years ago)
- Topics: graphql, koa-graphql-template, koa2, mongodb, mongoose, nodejs, type-graphql, typegoose, typescript
- Language: TypeScript
- Homepage:
- Size: 521 KB
- Stars: 44
- Watchers: 2
- Forks: 7
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypeScript and Koa GraphQL Server Template
This is a koa GraphQL template build with typescript
## Include
- Koa2
- apollo-server-koa v2
- GraphQL(use type-graphql)
- mongodb (use mongoose + typegoose as orm)
- eslint
- nodemon
- prettier## Getting Started
1. **install all dependencies**
`yarn`
2. **install mongodb**
`brew tap mongodb/brew`
`brew install [email protected]`
3. **start mongo service**
`brew services start [email protected]`
4. **start server**
`yarn serve`
5. **visit GraphQL**
`http://localhost:4000/graphql`
5.1 try to create a mutation
```
mutation {
saveInfo(data: { hobby:["唱","跳","rap","篮球"], height:"165", weight: 100}){
hobby
height
weight
}
}
```then you will see
![](https://user-gold-cdn.xitu.io/2020/3/26/171157c890f8e5e9?w=2860&h=846&f=png&s=40442)
5.2 try to query
```
query {
# students(age:22){
# sex
# name
# age
# }# studentsWithInfo {
# sex
# name
# age
# }infos {
_id
height
weight
hobby
}
}
```then you will see
![](https://user-gold-cdn.xitu.io/2020/3/26/171157666f5e2c69?w=2872&h=1478&f=png&s=86976)