Repository: mercurius-js/mercurius
Pull request #792 (2022-05-05 18:45:55)

Use new fastify plugin names for `@fastify/static` & `@fastify/error` & `@fastify/websocket` (#791)
`fastify-static & fastify-error & fastify-websocket -> @fastify/static & @fastify/error & @fastify/websocket`


Patch:
diff --git a/index.d.ts b/index.d.ts
index 64629d2..14998c0 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 58d934f..5e47425 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 8846130..cdd4f6a 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 009cc28..d4e3a20 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')
@@ -60,8 +60,8 @@ function createConnectionHandler ({ subscriber, fastify, onConnect, onDisconnect
 module.exports = function (fastify, opts, next) {
   const { getOptions, subscriber, verifyClient, onConnect, onDisconnect, lruGatewayResolvers, entityResolversFactory, subscriptionContextFn } = 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 b6075bc..3d4b478 100644
--- a/package.json
+++ b/package.json
@@ -56,12 +56,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": "^0.3.1",
     "fastify-plugin": "^3.0.0",
-    "fastify-static": "^4.2.2",
-    "fastify-websocket": "^4.0.0",
     "graphql": "^15.5.1",
     "graphql-jit": "^0.7.0",
     "mqemitter": "^4.4.1",


Test patch:
diff --git a/test/subscription.js b/test/subscription.js
index 0841f2b..6d5064a 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')