Skip to content

Unable to switch existing apollo federation gateway supporting azure function with apollo-server-integration-azure-functions #30

@mdv27

Description

@mdv27

Existing function

import { AzureFunction, Context, HttpRequest } from "@azure/functions";
import { ApolloServer } from "apollo-server-azure-functions";
import { ApolloGateway } from "@apollo/gateway";
import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';

const startApollo = () => {
  let handler: AzureFunction | undefined;
  const init = async () => {
    const gateway = new ApolloGateway({
      serviceList: [
        { name: 'subgraph-api', url: 'https://localhost:7071/api/graphql' }
      ]
    });
    const { schema, executor } = await gateway.load();
    const server = new ApolloServer({ schema, executor: executor as any, plugins: [ApolloServerPluginLandingPageGraphQLPlayground]});
    handler = server.createHandler()
    console.log("Apollo server started.");
  };

  init();

  return (context: Context, req: HttpRequest) => {
    if (handler) handler(context, req);
  };
};

exports.graphqlHandler = startApollo();

ApolloServer class in @apollo/server v4 does not support above constructor param executor. Also createHandler() not present. Please help.

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