Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • J jz-api-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • jizhi-backend
  • jz-api-core
  • Wiki
  • Home

Home · Changes

Page history
xigua created page: home authored Jul 06, 2017 by xigua's avatar xigua
Hide whitespace changes
Inline Side-by-side
Showing with 10 additions and 1 deletion
+10 -1
  • home.md home.md +10 -1
  • No files found.
home.md
View page @ 5dbfa393
......@@ -31,4 +31,13 @@
* Context - 最重要的对象之一,一个request在服务器的生命周期会贯穿着一个Context object,里面的一些属性非常用有
1. me - Me的实例,包含当前用户的信息
2. startTime - 这个context被初始化的时间
3. query - graphql的query信息
\ No newline at end of file
3. query/mutation/variables 等一些和graphql相关的信息,一般不用管
4. error - Error若出错,可以将错误设置到Context里,不过一般的处理方式是直接throw Error
* isAdmin(me: Me) - 函数,返回true如果当前用户是超级管理员
* initContext(query: string, variables: string, mutation: string, operationName: string, me: Me) - 函数,用于初始化一个Context,主要用户类似cron job这种不是从request初始化的context
* Query - 代表一个查询接口,包含四个fields
1. args - Object,所有Query一定要包含args,里面对应mongo的查询条件,比如 {_id: 'abcfd'}
2. limit - 分页时用,未提供的时候默认页面大小为100
3. sort - 排序
4. skip - 忽略多少条记录,用于mongo数据库查询分页时,返回指定页的数据时使用,比如页面大小limit=10,需要第三页时skip为20
* isLogin(me: Me) - 当前用户是否已经登录
Clone repository
  • Home
  • jz backend project skeleton