Apollo server is very slow even with light queries

Viewed 1022

I know that GraphQL can get slower with large data sets, but what I have is an array of around 60 items. E.g. in a simple query, I fetch, the id, title and country and it takes more than 3 ms on average for the Apollo server to return data while the resolver reruns data calling a REST endpoint in less than 200ms. I use Apollo studio to debug queries and what I get does not help me at all - everywhere less than 1 ms.

enter image description here

If I go for a more complex query with 2 nested queries, it take 15-20 seconds for the same 60 items and the nested queries are quite light.

I googled and found that people face similar issues with really heavy queries with thousands of items and they talk about a few seconds, not 15-20 seconds.

Feels like there is something wrong in my setup. I do not get any errors. I am using apollo-server-express with a basic setup:

const server = new ApolloServer({
  typeDefs,
  resolvers,
  introspection: true,
  playground: !(process.env.NODE_ENV === 'production'),
  engine: {
    reportSchema: true,
    graphVariant: 'current',
  },
  subscriptions: {
    onConnect: () => winston.info('Connected to websocket'),
    onDisconnect: webSocket => winston.info(`Disconnected from websocket ${webSocket}`),
  },
  context: ({ req }) => ({
    //eslint-disable-line
    req,
    pubSub,
  }),
});
0 Answers
Related