小编Man*_*iya的帖子

如何使用Server.inject注入模拟测试hapi

我想用实验室测试hapi路由,我正在使用mysql数据库.

使用Server.inject测试路由的问题是我无法模拟数据库因为我没有调用包含处理函数的文件,所以如何在处理程序中注入模拟数据库?

node.js sequelize.js node-mysql hapijs

12
推荐指数
1
解决办法
3041
查看次数

子解析器中的Graphql-Access参数

我正在使用apollo-server和apollo-graphql-tools,我有以下架构

type TotalVehicleResponse {
  totalCars: Int
  totalTrucks: Int
}

type RootQuery {
  getTotalVehicals(color: String): TotalVehicleResponse
}

schema {
  query: RootQuery
}
Run Code Online (Sandbox Code Playgroud)

和解析器功能是这样的

{
  RootQuery: {
    getTotalVehicals: async (root, args, context) => {
      // args = {color: 'something'}
      return {};
    },
    TotalVehicleResponse: {
      totalCars: async (root, args, conext) => {
        // args is empty({}) here
        .........
        .........
      },
      totalTrucks: async (root, args, conext) => {
        // args is empty({}) here
        .........
        .........
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是如何在任何子args解析器中访问root解析器(getTotalVehicals)中可用的?

apollo graphql graphql-js apollo-server

7
推荐指数
3
解决办法
3814
查看次数

在无服务器项目中如何/在何处运行迁移迁移?

我试图将Sequelize js与Serverless结合使用,它来自传统的服务器背景,我对在何处/如何运行数据库迁移感到困惑。

是否应该为运行迁移创建专用功能,或者是否还有其他运行迁移的方法?

migration sequelize.js serverless-framework sequelize-cli serverless-architecture

6
推荐指数
2
解决办法
1326
查看次数