Home > database >  Apollo Server context function executed every 2 seconds
Apollo Server context function executed every 2 seconds

Time:10-22

Is it normal that the context function of apollo-server-express is constantly executed in an interval?

const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: ({ event, context, express }) => {
    console.log('context')
  }
})

I can see a new log output in the console every 2 seconds or so.

Cheers

CodePudding user response:

From the The context argument docs:

This function is called with every request, so you can set the context based on the request's details (such as HTTP headers).

It will be executed each time a client request is received, rather than executed in an interval.

CodePudding user response:

I found the culprit or better one of the Apollo contributors found it.

According to Trevor from the Apollo team, this is the default behaviour when one is using the Graphql Playground, either the web version or the stand-alone app.

I hope that helps someone that discovers the same problem.

  • Related