mercurius
Advanced tools
Comparing version 9.3.6 to 9.4.0
@@ -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. |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
974955
18
149
34432
+ Added@fastify/error@^2.0.0
+ Added@fastify/static@^5.0.0
+ Added@fastify/websocket@^5.0.0
+ Added@fastify/busboy@2.1.1(transitive)
+ Added@fastify/error@2.0.0(transitive)
+ Added@fastify/static@5.0.2(transitive)
+ Added@fastify/websocket@5.0.1(transitive)
+ Addedundici@5.28.4(transitive)
- Removedfastify-error@^1.0.0
- Removedfastify-static@^4.2.2
- Removedfastify-websocket@^4.0.0
- Removedpromise.allsettled@^1.0.4
- Removedarray-buffer-byte-length@1.0.2(transitive)
- Removedarray.prototype.map@1.0.8(transitive)
- Removedarraybuffer.prototype.slice@1.0.4(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removeddata-view-buffer@1.0.2(transitive)
- Removeddata-view-byte-length@1.0.2(transitive)
- Removeddata-view-byte-offset@1.0.1(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-abstract@1.23.8(transitive)
- Removedes-array-method-boxes-properly@1.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-get-iterator@1.1.3(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-to-primitive@1.3.0(transitive)
- Removedfastify-error@1.1.01.2.0(transitive)
- Removedfastify-static@4.6.14.7.0(transitive)
- Removedfastify-websocket@4.2.24.3.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.8(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedget-symbol-description@1.1.0(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-bigints@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinternal-slot@1.1.0(transitive)
- Removedis-arguments@1.2.0(transitive)
- Removedis-array-buffer@3.0.5(transitive)
- Removedis-async-function@2.0.0(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.2(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-finalizationregistry@1.1.1(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-number-object@1.1.1(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.4(transitive)
- Removedis-string@1.1.1(transitive)
- Removedis-symbol@1.1.1(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakref@1.1.0(transitive)
- Removedis-weakset@2.0.4(transitive)
- Removedisarray@2.0.5(transitive)
- Removediterate-iterator@1.0.2(transitive)
- Removediterate-value@1.0.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedown-keys@1.0.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedpromise.allsettled@1.0.7(transitive)
- Removedreflect.getprototypeof@1.0.9(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedsafe-array-concat@1.1.3(transitive)
- Removedsafe-push-apply@1.0.0(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstop-iteration-iterator@1.1.0(transitive)
- Removedstring.prototype.trim@1.2.10(transitive)
- Removedstring.prototype.trimend@1.0.9(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedtyped-array-buffer@1.0.3(transitive)
- Removedtyped-array-byte-length@1.0.3(transitive)
- Removedtyped-array-byte-offset@1.0.4(transitive)
- Removedtyped-array-length@1.0.7(transitive)
- Removedunbox-primitive@1.1.0(transitive)
- Removedundici@4.16.0(transitive)
- Removedwhich-boxed-primitive@1.1.1(transitive)
- Removedwhich-builtin-type@1.2.1(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-typed-array@1.1.18(transitive)
Updatedfastify-plugin@^3.0.1
Updatedundici@^5.0.0