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/
Related
I am trying to connect my react native mobile app with graphql server. For that, as the graphql client I am using Apollo Client. I hope to use AWS services and, I have a problem in selecting the suitable graphql server.
Can I use AWS AppSync instead of using a separate GraphQL server such as ApolloServer, Express GraphQL etc.
Yes, you can use AWS AppSync as a GraphQL server on AWS. AWS AppSync is an AWS service for creating your fully managed GraphQL API layers. Since, it is a managed service, which means you don't need to worry about provisioning a server for your backend.
I would suggest you to use Serverless framework to manage and deploy your AppSync application. Here is the link for you to get started and will probably give you a good idea how to use Serverless for AppSync applications.
https://www.serverless.com/guides/aws-appsync
I have the "new" HTTP API with a DynamoDB and lambda, I want to provide support for my app to the macOS computers. Is it possible to use the HTTP API Gateway with Amplify? I only see an option for GraphQL and REST
Thaks
I am working on a project and trying to use API Gateway to invoke a lambda function. The lambda function is used to update a DynamoDB item. The DynamoDB table is used to keep a running count of visitors to a web page. I need to create an API to invoke the lambda function but I'm not sure how to create the API. Any assistance is appreciated.
General steps would be:
Create AWS_PROXY integration between API Gateway and your Lambda function. The example of this is in the AWS tutorials: Set up Lambda proxy integrations in API Gatewa and in Tutorial: Build a REST API with HTTP proxy integration
Add/amend execution role to your function allowing it to access DynamoDB. This is exemplified in the AWS tutorial: Using AWS Lambda with Amazon DynamoDB.
Test the API. It can be done directly in API gateway console, or using external tools such as curl or Postman.
I figured out my issue. In my lamdba function, I needed to change the output to a JSON object. Once I made the change, I was able to get my API working. Here is a link to the fix.
I am new to aws appsync api. Can anyone guide me for this question?
My Case:
I have one URL of RESTAPI endpoint which returns me JSON. Now I want to convert that RESTAPI to aws appsync api using that URL. How can I do that?
AppSync recently added a Rest API data source as an option and you can use this to map your rest api to a graphql interface.
You can use an AWS Lambda resolver to convert the REST API response to GraphQL in AppSync. The tutorial should help you get familiar with Lambda resolvers.
Is there a way for GraphQL resolver to resolve data source from endpoint exposed by a lambda function generated by CodeStar?
The examples provided in the AppSync docs shows how I resolve data from single lambda function, but in my case, I'm using AWS Codestar to generate a REST API using lambda, with several endpoints that returns different set of data.
For example, when I want to resolve a fetchPosts, i need to resolve it from https://my-prod-example-url/posts endpoint, not just invoke the lambda function.
I am on the AWS AppSync team. Http data sources are not available yet but they're very much on our roadmap.