1.1.6 • Published 6 years ago
oneql v1.1.6
oneQL
Use koa + apollo-server-koa book: (https://oneqljs.github.io/oneQL/book/)
Getting Started
- npm install oneql-init -g
- oneql-init project
- cd project && npm install && npm run dev
Init oneQL (oneql-init create boilerplate)
// src/index.ts
import oneql from 'oneql'
import typeDefs from './types'
import resolvers from './resolvers'
new oneql({
schema: {
typeDefs,
resolvers
},
context: async ({ ctx }) => {
return {
ctx
}
}
})
Example:
query db($key: String, $ext: [ExtensionType]){
hello
city(request: {key: $key, ext: $ext } ) {
datainfo{
CountryId
country
type
}
}
}
QUERY VARIABLES
{"key":"D", "ext": [{ "key":"2", "value":"1"}] }
query simple{
seatSimple {
resultList{
fInfo{
fNo
}
}
}
}
开发建议
- 一个请求可以带多个schema,对应请求逻辑是resolvers文件夹下index.js, connect所有resolvers
- 每一个最外层schema分一个对应的types文件和一个resolvers文件
- types文件夹下index.js , connect所有types
- 每一个schema具体数据实现,如果涉及请求,建议api文件夹里建一个文件处理逻辑
Util
- util提供了soa请求封装,如自动处理埋点信息;
- 提供xconfig集成;
- 提供redis方法集成
- 提供log方法集成
Production Environment
- close graphlQL playground
- app.config.js, env=prod // close
const server = new ApolloServer({
typeDefs,
// mocks
resolvers
// playground: false // false为关闭
})
Mind map
License
MIT
1.1.6
6 years ago
1.1.5
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago