Repository: mercurius-js/mercurius
Pull request #780 (2022-04-28 09:56:50)

chore: update fastify deps to @fastify
as titled

mcollina: patch

Patch:
diff --git a/docs/subscriptions.md b/docs/subscriptions.md
index 42957ed..b043b2c 100644
--- a/docs/subscriptions.md
+++ b/docs/subscriptions.md
@@ -8,7 +8,7 @@
   - [Build a custom GraphQL context object for subscriptions](#build-a-custom-graphql-context-object-for-subscriptions)
   - [Subscription support (with redis)](#subscription-support-with-redis)
   - [Subscriptions with custom PubSub](#subscriptions-with-custom-pubsub)
-  - [Subscriptions with fastify-websocket](#subscriptions-with-fastify-websocket)
+  - [Subscriptions with @fastify/websocket](#subscriptions-with-fastify-websocket)
 
 ### Subscription support (simple)
 
@@ -322,12 +322,12 @@ app.register(mercurius, {
 
 ```
 
-### Subscriptions with fastify-websocket
+### Subscriptions with @fastify/websocket
 
-Mercurius uses `fastify-websocket` internally, but you can still use it by registering before `mercurius` plugin. If so, it is recommened to set the appropriate `options.maxPayload` like this:
+Mercurius uses `@fastify/websocket` internally, but you can still use it by registering before `mercurius` plugin. If so, it is recommened to set the appropriate `options.maxPayload` like this:
 
 ```js
-const fastifyWebsocket = require('fastify-websocket')
+const fastifyWebsocket = require('@fastify/websocket')
 
 app.register(fastifyWebsocket, {
   options: {
diff --git a/index.d.ts b/index.d.ts
index 0d6fb97..d920753 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -13,7 +13,7 @@ import {
   GraphQLScalarType,
   ValidationRule,
 } from "graphql";
-import { SocketStream } from "fastify-websocket"
+import { SocketStream } from "@fastify/websocket"
 import { IncomingMessage, IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
 import { Readable } from "stream";
 
diff --git a/lib/errors.js b/lib/errors.js
index 08daee0..6dc659c 100644
--- a/lib/errors.js
+++ b/lib/errors.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { formatError, GraphQLError } = require('graphql')
-const createError = require('fastify-error')
+const createError = require('@fastify/error')
 
 class ErrorWithProps extends Error {
   constructor (message, extensions, statusCode) {
diff --git a/lib/routes.js b/lib/routes.js
index efce708..f3be958 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { join } = require('path')
-const Static = require('fastify-static')
+const Static = require('@fastify/static')
 const subscription = require('./subscription')
 const { kRequestContext } = require('./symbols')
 const sJSON = require('secure-json-parse')
diff --git a/lib/subscription.js b/lib/subscription.js
index 7274243..f21e6be 100644
--- a/lib/subscription.js
+++ b/lib/subscription.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const fastifyWebsocket = require('fastify-websocket')
+const fastifyWebsocket = require('@fastify/websocket')
 const { assignLifeCycleHooksToContext, Hooks } = require('./hooks')
 const { kHooks } = require('./symbols')
 const SubscriptionConnection = require('./subscription-connection')
@@ -62,8 +62,8 @@ function createConnectionHandler ({ subscriber, fastify, onConnect, onDisconnect
 module.exports = function (fastify, opts, next) {
   const { getOptions, subscriber, verifyClient, onConnect, onDisconnect, lruGatewayResolvers, entityResolversFactory, subscriptionContextFn, keepAlive, fullWsTransport } = opts
 
-  // If `fastify.websocketServer` exists, it means `fastify-websocket` already registered.
-  // Without this check, fastify-websocket will be registered multiple times and raises FST_ERR_DEC_ALREADY_PRESENT.
+  // If `fastify.websocketServer` exists, it means `@fastify/websocket` already registered.
+  // Without this check, @fastify/websocket will be registered multiple times and raises FST_ERR_DEC_ALREADY_PRESENT.
   if (fastify.websocketServer === undefined) {
     fastify.register(fastifyWebsocket, {
       options: {
diff --git a/package.json b/package.json
index 33daa13..6bd3b35 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
     "autocannon": "^7.3.0",
     "concurrently": "^7.0.0",
     "docsify-cli": "^4.4.3",
-    "fastify": "^3.18.1",
+    "fastify": "^3.28.0",
     "pre-commit": "^1.2.2",
     "proxyquire": "^2.1.3",
     "sinon": "^13.0.0",
@@ -53,12 +53,12 @@
     "wait-on": "^6.0.0"
   },
   "dependencies": {
+    "@fastify/error": "^2.0.0",
+    "@fastify/static": "^5.0.0",
+    "@fastify/websocket": "^5.0.0",
     "@types/isomorphic-form-data": "^2.0.0",
     "events.on": "^1.0.1",
-    "fastify-error": "^1.0.0",
-    "fastify-plugin": "^3.0.0",
-    "fastify-static": "^4.2.2",
-    "fastify-websocket": "^4.0.0",
+    "fastify-plugin": "^3.0.1",
     "graphql": "^16.0.0",
     "graphql-jit": "^0.7.3",
     "mqemitter": "^4.4.1",


Test patch:
diff --git a/test/subscription.js b/test/subscription.js
index 4b6b2a0..1dc3d8b 100644
--- a/test/subscription.js
+++ b/test/subscription.js
@@ -3,7 +3,7 @@ const Fastify = require('fastify')
 const WebSocket = require('ws')
 const mq = require('mqemitter')
 const { EventEmitter } = require('events')
-const fastifyWebsocket = require('fastify-websocket')
+const fastifyWebsocket = require('@fastify/websocket')
 const GQL = require('..')
 
 const FakeTimers = require('@sinonjs/fake-timers')
@@ -1767,7 +1767,7 @@ test('`withFilter` tool works with async filters', t => {
   })
 })
 
-test('subscription server works with fastify-websocket', t => {
+test('subscription server works with fastify websocket', t => {
   const app = Fastify()
   t.teardown(() => app.close())
   t.plan(3)