如何将Apollo服务器连接到AWS Lambda服务?

问题描述

我想将Apollo服务器连接到我具有要查询的模型的“ Python” Lambda服务。我到处搜索,但只能找到使Apollo服务器本身成为AWS Lambda服务的示例。

我创建了一个连接到lambda服务的AWS API网关。
这是我拥有的服务器代码

const { ApolloGateway,RemoteGraphQLDataSource } = require('@apollo/gateway');
const { ApolloServer,gql } = require('apollo-server');

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'clients',url: 'AWS_API_GATEWAY_URL'}
  ],buildService({ name,url }){
    return new RemoteGraphQLDataSource({
      url,willSendRequest({ request,context }) {
        request.http.headers.set(
          "user",context.user ? JSON.stringify(context.user) : null
        );
      }
    });
  }
});

const server = new ApolloServer({
    gateway,subscriptions: false
});
server.listen(3000).then(({ url }) => {
  console.log(`Server ready at ${url}`);
});

但是即使尝试启动服务器也会出现此错误Error checking for changes to service deFinitions: Couldn't load service deFinitions for "reports" at AWS_GATEWAY_URL

有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)