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

Add body to context function #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/func-v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import type { WithRequired } from '@apollo/utils.withrequired';

export interface AzureFunctionsContextFunctionArgument {
context: InvocationContext;
req: HttpRequest;
// Omit the body parsing methods from the HttpRequest type, since at this point the body has already been parsed
// if the user try to use the body parsing methods, it will throw an error
req: Omit<
HttpRequest,
'body' | 'arrayBuffer' | 'blob' | 'formData' | 'json' | 'text'
>;
body: unknown;
}

export interface AzureFunctionsMiddlewareOptions<TContext extends BaseContext> {
Expand Down Expand Up @@ -47,7 +53,7 @@ export function startServerAndCreateHandler<TContext extends BaseContext>(

const { body, headers, status } = await server.executeHTTPGraphQLRequest({
httpGraphQLRequest: normalizedRequest,
context: () => contextFunction({ context, req }),
context: () => contextFunction({ context, req, body: normalizedRequest.body }),
});

if (body.kind === 'chunked') {
Expand Down
Loading