Nest: @nestjs/platform-fastify 7.4 is a breaking change

Created on 30 Jul 2020  路  7Comments  路  Source: nestjs/nest

Bug Report

Current behavior

7.2.x requires fastify 2.x.
7.4.x requires fastify 3.x.
Using 7.4x is breaking projects with fastify 2.x dependencies

const serverOptions: fastify.ServerOptionsAsHttp = {
    logger: ['log', 'error', 'warn'],
  };

throws error: Namespace '"/node_modules/fastify/fastify"' has no exported member 'ServerOptionsAsHttp'. ts(2694) [90, 32]

const instance: fastify.FastifyInstance = fastify(serverOptions);

throws error: This expression is not callable.
Type 'typeof import("/node_modules/fastify/fastify")' has no call signatures.

Input Code

import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import * as fastify from '../node_modules/fastify';

let fastifyServer: fastify.FastifyInstance;

async function bootstrap(): Promise<fastify.FastifyInstance> {
  const serverOptions: fastify.ServerOptionsAsHttp = {
    logger: ['log', 'error', 'warn'],
  };
  const instance: fastify.FastifyInstance = fastify(serverOptions);
  const nestApp = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(instance),
    {
      logger: ['log', 'error', 'warn'],
    },
  );

Expected behavior

Minor increments are non-breaking

Possible Solution

7.4 should be 8.x

Environment


Nest version: 6.14.1


For Tooling issues:
- Node version: 12.13.0
- Platform:  Mac

Others:
Using npm and VSCode
needs triage

Most helpful comment

It is also a breaking change for projects using GraphQL with Fastify, as apollo-server-fastify does not support Fastify 3.x for now.

All 7 comments

same here, is breaking the Exception filters.

It is also a breaking change for projects using GraphQL with Fastify, as apollo-server-fastify does not support Fastify 3.x for now.

I have the same problem with GraphQL using Fastify with apollo-server-fastify.

I have the same problem with GraphQL using Fastify with apollo-server-fastify

@robinsmedberg Check it out. I'm waiting too for the update from apollo-server-fastify for upgrade to Fastify v3. This is in alpha now.

https://github.com/nestjs/nest/issues/5055#issuecomment-696982213

works fine in "@nestjs/common": "^7.5.2" , "@nestjs/platform-fastify": "^7.5.2",

Also works fine for GraphQL with the following versions

"@nestjs/common": "^7.5.5",
"@nestjs/core": "^7.5.5",
"@nestjs/graphql": "^7.8.2",
"@nestjs/platform-fastify": "^7.5.5",
"apollo-server-fastify": "^2.19.0"

Though the GraphQL playground is not working with [email protected]. The next alpha release is required ([email protected]), see https://github.com/apollographql/apollo-server/issues/4463

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marshall007 picture marshall007  路  3Comments

tronginc picture tronginc  路  3Comments

janckerchen picture janckerchen  路  3Comments

2233322 picture 2233322  路  3Comments

VRspace4 picture VRspace4  路  3Comments