Skip to content

Lambda Stream Support#118

Draft
BlenderDude wants to merge 7 commits into
mainfrom
da/lambda-stream-support
Draft

Lambda Stream Support#118
BlenderDude wants to merge 7 commits into
mainfrom
da/lambda-stream-support

Conversation

@BlenderDude

Copy link
Copy Markdown
Member

No description provided.

@changeset-bot

changeset-bot Bot commented Aug 1, 2023

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 435d5c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codesandbox-ci

codesandbox-ci Bot commented Aug 1, 2023

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit dc52277:

Sandbox Source
apollo-server-integration-aws-lambda Configuration

In runMiddleware, when a middleware function returned an object (early
result), it was returned unwrapped. lambdaHandler then assigned
`resultMiddlewareFns = middlewareResult.middleware` which resolved to
`undefined`, causing `TypeError: resultMiddlewareFns is not iterable`
in the catch block on subsequent errors.

Fixed by wrapping the early return as `{ status: 'result', result }`.

Also adds:
- runMiddleware unit tests (empty list, callbacks, early return,
  middleware throw, callback flush on throw)
- streamHandler.test.ts covering isStreamRequestHandler,
  createStreamRequestHandler (fromEvent, buildHTTPMetadata,
  toErrorResult), and stream lambda handler integration paths
Add awslambda and streamify to cspell-dict.txt, and apply prettier
formatting to middleware.test.ts, streamHandler.test.ts, and _create.ts.
StreamRequestHandler.toErrorResult is async and returns {metadata, body},
not HttpMetadata. Calling it without await in runMiddleware's catch block
produced a Promise where HttpMetadata was expected, causing undefined
behaviour when middleware throws in stream mode.

Fix by re-throwing for stream handlers — the stream path in lambdaHandler
already has its own catch that properly awaits toErrorResult and writes
the error response to the stream. Adds a test to cover this path.
Adds a mock HTTP adapter and integration test that run Apollo's full
defineIntegrationTestSuite against the V2 stream handler (with and
without base64 encoding). Also fixes buildHTTPMetadata to include
content-length for complete responses, matching the non-streaming handlers.
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

Successfully merging this pull request may close these issues.

2 participants