Apollo Server context function executed every 2 seconds

Viewed 486

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

3 Answers

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.

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.

I am using Apollo Studio and In there It has this setting called 'Auto-Update' Which will request every second to stay in sync with Schema of GraphQL on our server.

Auto Update setting in Apollo Server

We can simply disable it to stop making requests every second ! but if we were to change the schema then we'll have to refresh manually.

Related