Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oneqljs/oneql

简单、轻量的 Nodejs服务端 Graphql 渐进式解决方案
https://github.com/oneqljs/oneql

apollo-graphql apollo-graphql-server graphql graphql-framework graphql-server koa koa2 nodejs nodejs-framework

Last synced: 27 days ago
JSON representation

简单、轻量的 Nodejs服务端 Graphql 渐进式解决方案

Awesome Lists containing this project

README

        

oneQL
--------
Use koa + apollo-server-koa

book: (https://oneqljs.github.io/oneQL/book/)

[![npm][npm]][npm-url]
[![node][node]][node-url]
[![Downloads][downloads-image]][npm-url]
[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)]()

Getting Started
---------
- npm install oneql-init -g
- oneql-init project
- cd project && npm install && npm run dev

#### Init oneQL (oneql-init create boilerplate)

```sh
// 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:
- Open:(http://localhost:3600/graphql)

```js
query db($key: String, $ext: [ExtensionType]){
hello
city(request: {key: $key, ext: $ext } ) {
datainfo{
CountryId
country
type
}
}
}
```

##### QUERY VARIABLES
```js
{"key":"D", "ext": [{ "key":"2", "value":"1"}] }
```

![avatar](./doc/oneQL-example.png)

```js
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

```js
const server = new ApolloServer({
typeDefs,
// mocks
resolvers
// playground: false // false为关闭
})
```

Mind map
--------
![avatar](./doc/oneQL_n.png)

[npm]: https://img.shields.io/npm/v/oneql.svg
[npm-url]: https://npmjs.com/package/oneql

[node]: https://img.shields.io/node/v/oneql.svg
[node-url]: https://nodejs.org

[downloads-image]: https://img.shields.io/npm/dm/oneql.svg

License
------
MIT