amazon-web-services - Do I have to use AppSync for apollo graphql in lambda?
问题描述
I'd like to use apollo graphql in a lambda and I found AppSync is for graphql and API Gateway is for REST. Do I have to use AppSync
for that?
I also find out a library apollo-server-lambda
which can be used with serverless
but I don't want to use serverless
because all my infrastructure code is written in Terraform. I don't want to bring another IaC library in my application.
So is there a way to use API Gateway with apollo graphql in lambda? If yes, how should I declare API Gateway route for that?
解决方案
Not really. You can just use the API gateway, Lambda, and Apollo Server. Install the npm library apollo-server-lambda
and Import the required modules.
The current version of Apollo Server Lambda: 2.17.0
You can create a GraphQL handler using the function createHandler
provided by Apollo server Lambda.
I am not sure about how it is done using Terraform but you can just declare a route to your handler function via the API gateway.
Make sure your GET and POST requests route to the same handler.
Refer to this documentation for more details: https://www.apollographql.com/docs/apollo-server/deployment/lambda/
推荐阅读
- jquery - 很多 Div 需要从绿色变为白色,从白色变为红色
- android - Android SDK 中缺少 AAPT2
- java - 退出android中的活动后重新加载片段
- javascript - 在单击下拉菜单中的链接时调用 javascript 函数时输入错误意外结束
- c# - OpenQA.Selenium.ElementNotInteractableException:无法点击元素
- node.js - 如何正确地将 http 请求包装在路由表达处理器中并推断出 HTML 中的答案?
- python - 我的程序有错误,无法找出它不起作用的原因
- laravel - php支付网关安全问题
- python-3.x - 长时间拆包时溢出 - Pytorch
- c# - 如何使用 C# 中具有标识列的 2 个查询更新 2 个 sqlserver 表?