Skip to content

Unable to send custom response headers #58

@ChristianRich

Description

@ChristianRich

I have a requirement to set cookies and response headers for my Azure/Apollo 4 GraphQL API.
Example resolver setting a cookie and a custom response header.

import type { Context } from "@azure/functions";

const resolvers = {
  Query: {
    hello: (_: unknown, args: unknown, context: Context): String => {
      const myCookie = cookie.serialize("my-cookie", `test-${Math.random()}`, {
        maxAge: 86400,
        httpOnly: true,
        sameSite: "none",
        secure: false,
      });

      context?.res?.headers["Set-Cookie"] = myCookie;
      context?.res?.headers["x-correlation-id"] = "1234";
      return "hello";
    },
  },
};

However, this will currently not work since apollo-server-integration-azure-functions ignores context.res?.headers when serving the API response to the Azure Function.

https://github.com/apollo-server-integrations/apollo-server-integration-azure-functions/blob/main/src/index.ts#L59

However this change makes it work:

2f9aec9

Is this an oversight or am I using the library incorrectly?

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