Skip to content

HttpRequest is mangled before context function in 0.2.2 #93

@shellicar-eagers

Description

@shellicar-eagers

Passing an HttpRequest to the handler should not result in the request getting mangled.

Behaviour before 0.2.2: context is created and returned.
Behaviour on 0.2.2: Context creation failed: Request is not an instance of HttpRequest

import { ApolloServer } from '@apollo/server';
import { v4 } from '@as-integrations/azure-functions';
import { app, HttpRequest } from '@azure/functions';

const server = new ApolloServer({
  // config
});

const createContext = async (args: v4.AzureFunctionsContextFunctionArgument) => {
  if (args.req instanceof HttpRequest) {
    return {};
  }
  throw new Error('Request is not an instance of HttpRequest');
}

const handler = v4.startServerAndCreateHandler(server, {
  context: createContext,
});

app.http('graphql', {
  authLevel: 'anonymous',
  methods: ['GET', 'POST', 'OPTIONS'],
  handler,
});

This seems to be because of this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions