在GraphQL上返回一个计数对象

时间:2018-05-10 12:12:31

标签: typescript graphql

我正在尝试创建一个GraphQL查询,该查询收集React项目的多个计数,但我无法确定应该输入的确切类型。

守则:

    import {   GraphQLInt,   GraphQLNonNull } from 'graphql' import * as moment from 'moment' import orm from '../../orm' import authDecorator from '../helpers/auth-decorator'

interface IQueryMissionCountArgs {   authToken: string }

export default authDecorator({   requireAdmin: true,   requireAuth: true })({   type: Object(new GraphQLNonNull(GraphQLInt)),   async resolve (
      args: IQueryMissionCountArgs   ) {
    const lastWeekAcceptedMissionsCount = await orm.models.Mission.count({
      where: {
        createdAt: {
          $between: [moment().subtract(7, 'days').toDate(), new Date()]
        },
        status: 'accepted'
      }
    })
    const lastWeekPostedMissionsCount = await orm.models.Mission.count({
      where: {
        createdAt: {
          $between: [moment().subtract(7, 'days').toDate(), new Date()]
        }
      }
    })
    return {
      lastWeekPostedMissions: lastWeekPostedMissionsCount,
      lastWeekAcceptedMissions: lastWeekAcceptedMissionsCount,
    }   } })

这是返回此错误:

  

Int不能表示非32位有符号整数值:[object Object] \ n

0 个答案:

没有答案