Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local testing #148

Open
michaelCaleyWhaley opened this issue Nov 6, 2023 · 4 comments
Open

Local testing #148

michaelCaleyWhaley opened this issue Nov 6, 2023 · 4 comments

Comments

@michaelCaleyWhaley
Copy link

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
Copy link
Member

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
Copy link

@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
Copy link

Im getting the same problem @DarlonHenrique

@bentburton
Copy link

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

  • http:
    path: /
    method: post
    cors: true

Changed to this

  • httpApi:
    path: /
    method: post
    cors: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants