Skip to content

Commit

Permalink
chore: update fastify deps to @fastify (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Sanfratello authored Apr 28, 2022
1 parent 49e9a50 commit d26a635
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions docs/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
6 changes: 3 additions & 3 deletions lib/subscription.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d26a635

Please sign in to comment.