Skip to content

logger access #59

Open
Open
@Falven

Description

@Falven

Apollo server has a logger option that you can set to determine the logger it should use.
Azure Functions provide the logger via the context object such that your logger logs to App Insights.
However, this integration needs you to initialize and pass in the server object before you can access the context.
Is there any way to set Apollo's logger to the logger from Azure context?

const server = new ApolloServer<MyApiContext>({
  typeDefs,
  resolvers,
  formatError: (formattedError: GraphQLFormattedError): GraphQLFormattedError => {
    context.log.error({
      error: formattedError.message,
      locations: formattedError.locations,
      path: formattedError.path,
      extensions: formattedError.extensions,
    });
    return formattedError;
  },
  includeStacktraceInErrorResponses: NODE_ENV === 'development',
  logger: ???
});

const azureFunction = startServerAndCreateHandler(server, {
  context: async ({ req, context: { log } }): Promise<MyApiContext> => {
  ...
  },
});

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