graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Apollo + Fastify version conflicts

Open roypeled opened this issue 8 months ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current behavior

Trying to upgrade nestjs to latest versions I encounter peer deps conflicts. I am using fastify, so I have @nestjs/platform-fastify installed. upgraded to v11 it has a peer dep to "fastify": "5.3.0".

I upgraded @nestjs/apollo to 13.1.0. it has a peer dep to @as-integrations/fastify: 2.1.1

@as-integrations/fastify has not been updated for the past 2 years. It has a peer dependency to "fastify": "^4.4.0".

Running the server without @as-integrations/fastify breaks with an error The "@as-integrations/fastify" package is missing. Please, make sure to install it to take advantage of GraphQLModule from this line(https://github.com/nestjs/graphql/blob/master/packages/apollo/lib/drivers/apollo-base.driver.ts#L179)

However the @nestjs/apollo documentation doesn't even mention this lib: https://www.npmjs.com/package/@nestjs/apollo instead asking to install apollo-server-fastify which has been deprecated (https://www.npmjs.com/package/apollo-server-fastify)

If there is any alternative, please suggest it, otherwis issue a breaking change to the latest versions describing that apollo no longer supports fastify.

Minimum reproduction code

https://www.npmjs.com/package/apollo-server-fastify

Steps to reproduce

npm i @nestjs/platform-fastify npm i @nestjs/apollo npm I fastify npm i @as-integrations/fastify OR npm i apollo-server-fastify

Expected behavior

either remove @as-integrations/fastify dependency or deprecate fastify

Package version

13.1.0

Graphql version

graphql: 16.10.0 apollo-server-express: NA apollo-server-fastify: 3.13.0

NestJS version

11.0.16

Node.js version

v20.18.1

In which operating systems have you tested?

  • [x] macOS
  • [ ] Windows
  • [ ] Linux

Other

No response

roypeled avatar Apr 14 '25 12:04 roypeled

If you use the @nestjs/platform-fastify package, I recommend that you do not use the @as-integrations/fastify package, which does not seem to be up-to-date anymore, the last change was 2 years ago. Better to use mercurius, the following explains how to install it:

# Fastify and Mercurius
npm i @nestjs/graphql @nestjs/mercurius graphql mercurius

An alternative can be Graphql Yoga, if you might be interested it also works with Fastify, see here: https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nestjs.

I hope I have been helpful 🙂

Tony133 avatar Apr 21 '25 14:04 Tony133

Yes, it's sad to say, but the best thing is to switch to Yoga; my project was immediately compatible, and it's also faster.

https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nestjs.

maltyxx avatar Oct 02 '25 18:10 maltyxx