Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mercurius

Package Overview
Dependencies
Maintainers
2
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercurius - npm Package Compare versions

Comparing version 9.3.6 to 9.4.0

docs/integrations/nestjs.md

1

docs/integrations/README.md

@@ -10,1 +10,2 @@ # mercurius

- [@opentelemetry](/docs/integrations/open-telemetry.md) - A framework for collecting traces and metrics from applications.
- [NestJS](/docs/integrations/nestjs.md) - Use Typescript classes and decorators, along with a powerful modularization system and a lot of other great tools for a very good developer experience in terms of GraphQL API automation.

8

docs/subscriptions.md

@@ -11,3 +11,3 @@ # mercurius

- [Subscriptions with custom PubSub](#subscriptions-with-custom-pubsub)
- [Subscriptions with fastify-websocket](#subscriptions-with-fastify-websocket)
- [Subscriptions with @fastify/websocket](#subscriptions-with-fastify-websocket)

@@ -326,8 +326,8 @@ ### Subscription support (simple)

### 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')

@@ -334,0 +334,0 @@ app.register(fastifyWebsocket, {

@@ -30,2 +30,3 @@

* [Tracing - OpenTelemetry](/docs/integrations/open-telemetry)
* [NestJS](/docs/integrations/nestjs.md)
* [Related Plugins](/docs/plugins)

@@ -32,0 +33,0 @@ * [mercurius-auth](/docs/plugins#mercurius-auth)

@@ -16,3 +16,3 @@ import {

} from "graphql";
import { SocketStream } from "fastify-websocket"
import { SocketStream } from "@fastify/websocket"
import { IncomingMessage, IncomingHttpHeaders, OutgoingHttpHeaders } from "http";

@@ -388,4 +388,9 @@ import { Readable } from "stream";

mandatory?: boolean;
initHeaders?: (() => OutgoingHttpHeaders | Promise<OutgoingHttpHeaders>) | OutgoingHttpHeaders;
rewriteHeaders?: <TContext extends MercuriusContext = MercuriusContext>(headers: IncomingHttpHeaders, context: TContext) => OutgoingHttpHeaders;
initHeaders?:
| (() => OutgoingHttpHeaders | Promise<OutgoingHttpHeaders>)
| OutgoingHttpHeaders;
rewriteHeaders?: <TContext extends MercuriusContext = MercuriusContext>(
headers: IncomingHttpHeaders,
context: TContext
) => OutgoingHttpHeaders | Promise<OutgoingHttpHeaders>;
connections?: number;

@@ -392,0 +397,0 @@ keepAlive?: number;

@@ -172,5 +172,5 @@ 'use strict'

? new GraphQLObjectType({
name: 'Mutation',
fields: {}
})
name: 'Mutation',
fields: {}
})
: undefined

@@ -177,0 +177,0 @@ })

'use strict'
const { formatError, GraphQLError } = require('graphql')
const createError = require('fastify-error')
const createError = require('@fastify/error')

@@ -6,0 +6,0 @@ class ErrorWithProps extends Error {

@@ -22,3 +22,2 @@ 'use strict'

const getQueryResult = require('./gateway/get-query-result')
const allSettled = require('promise.allsettled')

@@ -427,3 +426,3 @@ function isDefaultType (type) {

const $refreshResult = await allSettled(
const $refreshResult = await Promise.allSettled(
Object.values(serviceMap).map((service) =>

@@ -487,3 +486,3 @@ service.refresh().catch((err) => {

await allSettled(
await Promise.allSettled(
Object.values(serviceMap).map((service) =>

@@ -490,0 +489,0 @@ service.reconnectSubscription()

@@ -43,2 +43,7 @@ 'use strict'

try {
const newHeaders = await rewriteHeaders(
opts.originalRequestHeaders,
opts.context
)
const response = await agent.request({

@@ -48,3 +53,3 @@ method: opts.method,

headers: {
...rewriteHeaders(opts.originalRequestHeaders, opts.context),
...newHeaders,
...opts.headers

@@ -51,0 +56,0 @@ },

@@ -122,3 +122,3 @@ 'use strict'

const serviceConfig = {
mandatory: mandatory,
mandatory,
sendRequest: sendRequest(request, url, useSecureParse),

@@ -125,0 +125,0 @@ close,

'use strict'
const { join } = require('path')
const Static = require('fastify-static')
const Static = require('@fastify/static')
const subscription = require('./subscription')

@@ -6,0 +6,0 @@ const { kRequestContext } = require('./symbols')

'use strict'
const fastifyWebsocket = require('fastify-websocket')
const fastifyWebsocket = require('@fastify/websocket')
const { assignLifeCycleHooksToContext, Hooks } = require('./hooks')

@@ -65,4 +65,4 @@ const { kHooks } = require('./symbols')

// 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) {

@@ -69,0 +69,0 @@ fastify.register(fastifyWebsocket, {

{
"name": "mercurius",
"version": "9.3.6",
"version": "9.4.0",
"description": "Fastify GraphQL adapter with gateway and subscription support",

@@ -38,8 +38,8 @@ "main": "index.js",

"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"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",

@@ -50,5 +50,5 @@ "proxyquire": "^2.1.3",

"split2": "^4.0.0",
"standard": "^16.0.3",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.19.0",
"tsd": "^0.20.0",
"typescript": "^4.3.5",

@@ -58,8 +58,8 @@ "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",

@@ -69,3 +69,2 @@ "graphql-jit": "^0.7.3",

"p-map": "^4.0.0",
"promise.allsettled": "^1.0.4",
"readable-stream": "^3.6.0",

@@ -76,3 +75,3 @@ "safe-stable-stringify": "^2.3.0",

"tiny-lru": "^8.0.1",
"undici": "^4.8.0",
"undici": "^5.0.0",
"ws": "^8.2.2"

@@ -82,3 +81,6 @@ },

"directory": "test/types"
},
"engines": {
"node": ">=12.9.0"
}
}

@@ -9,2 +9,3 @@ /* global React:false ReactDOM:false GraphiQL:false */

script.src = url
script.crossOrigin = 'anonymous'
script.addEventListener('load', () => resolve(script), false)

@@ -49,2 +50,3 @@ script.addEventListener('error', (err) => reject(err), false)

link.media = 'screen,print'
link.crossOrigin = 'anonymous'
document.getElementsByTagName('head')[0].appendChild(link)

@@ -51,0 +53,0 @@

@@ -1165,3 +1165,3 @@ 'use strict'

app.register(GQL, { schema: schema })
app.register(GQL, { schema })

@@ -1168,0 +1168,0 @@ app.register(async function (app) {

@@ -58,3 +58,3 @@ 'use strict'

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -149,3 +149,3 @@ })

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -152,0 +152,0 @@ })

@@ -56,3 +56,3 @@ 'use strict'

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -227,3 +227,3 @@ })

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -292,3 +292,3 @@ })

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -449,3 +449,3 @@ })

`,
resolvers: resolvers,
resolvers,
federationMetadata: true

@@ -966,3 +966,3 @@ })

`,
resolvers: resolvers,
resolvers,
federationMetadata: true,

@@ -969,0 +969,0 @@ subscription: true

@@ -95,3 +95,3 @@ 'use strict'

const rewriteHeaders = () => ({ 'x-custom': custom })
const rewriteHeaders = async () => ({ 'x-custom': custom })
const url = `http://localhost:${usersPort}/graphql`

@@ -98,0 +98,0 @@ gateway.register(GQL, { gateway: { services: [{ name: 'user', url, rewriteHeaders }] } })

@@ -644,3 +644,3 @@ 'use strict'

payload: {
query: query
query
}

@@ -647,0 +647,0 @@ }))

@@ -305,3 +305,3 @@ 'use strict'

payload: {
query: query
query
}

@@ -345,3 +345,3 @@ }))

payload: {
query: query
query
}

@@ -387,3 +387,3 @@ }))

payload: {
query: query
query
}

@@ -390,0 +390,0 @@ }))

@@ -6,3 +6,3 @@ const { test } = require('tap')

const { EventEmitter } = require('events')
const fastifyWebsocket = require('fastify-websocket')
const fastifyWebsocket = require('@fastify/websocket')
const GQL = require('..')

@@ -1771,3 +1771,3 @@

test('subscription server works with fastify-websocket', t => {
test('subscription server works with fastify websocket', t => {
const app = Fastify()

@@ -1774,0 +1774,0 @@ t.teardown(() => app.close())

@@ -60,3 +60,3 @@ import { expectAssignable, expectError } from 'tsd'

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -87,3 +87,3 @@ loaders: {},

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -328,2 +328,25 @@ loaders: {},

// Async rewriteHeaders
gateway.register(mercurius, {
gateway: {
services: [
{
name: 'user',
url: 'http://localhost:4001/graphql',
schema: `
type Query {
dogs: [Dog]
}`,
keepAlive: 3000,
rewriteHeaders: async (headers, context) => {
const sessionId = await Promise.resolve('12')
return {
sessionId
}
}
}
]
}
})
// keepAlive value in service config

@@ -435,3 +458,3 @@ gateway.register(mercurius, {

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -444,3 +467,3 @@ subscription: true

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -477,3 +500,3 @@ subscription: {

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -495,3 +518,3 @@ subscription: {

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -504,3 +527,3 @@ subscription: {

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -600,3 +623,3 @@ subscription: {

app.register(mercurius, {
schema: schema,
schema,
resolvers,

@@ -603,0 +626,0 @@ subscription: {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc