apollo-server-integrations / apollo-server-integration-aws-lambda

An integration to use AWS Lambda as a hosting service with Apollo Server
MIT License
46 stars 9 forks source link

Local testing #148

Open michaelCaleyWhaley opened 1 year ago

michaelCaleyWhaley commented 1 year ago

Hi

It'd be really helpful for me if there could be a local testing example in the docs. Currently using a different entry point for the local and hosted version of my subgraph Hosted import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda';

Local import { startStandaloneServer } from '@apollo/server/standalone';

This is making it difficult to test things such as middleware

BlenderDude commented 1 year ago

I considered adding a local testing suite to this library, but after much consideration decided it would be out-of-scope. There are other tools and libraries for developing locally with lambda. My personal recommendation is to unit test your middleware, and integration test it with a real lambda deployment. If you're using infrastructure as code like the cdk, this should be as easy as a cdk deploy and a cdk destroy in the test environment.

DarlonHenrique commented 12 months ago

@BlenderDude when i try to run locally with serverless invoke local --function, i get a { "statusCode": 400, "body": "Cannot read properties of undefined (reading 'http')" }

any solution for that?

bentburton commented 9 months ago

Im getting the same problem @DarlonHenrique

bentburton commented 9 months ago

I was able to fix this isssue by converting my events to API Gateway V2 https://www.serverless.com/framework/docs/providers/aws/events/http-api

Changed to this