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.4.0 to 9.5.0

19

index.js

@@ -154,2 +154,21 @@ 'use strict'

if (gateway && Array.isArray(gateway.services)) {
const serviceNames = new Set()
for (const service of gateway.services) {
if (typeof service !== 'object') {
throw new MER_ERR_INVALID_OPTS('gateway: all "services" must be objects')
}
if (typeof service.name !== 'string') {
throw new MER_ERR_INVALID_OPTS('gateway: all "services" must have a "name" String property')
}
if (serviceNames.has(service.name)) {
throw new MER_ERR_INVALID_OPTS(`gateway: all "services" must have a unique "name": "${service.name}" is already used`)
}
serviceNames.add(service.name)
if (typeof service.url !== 'string' && (!Array.isArray(service.url) || service.url.length === 0 || !service.url.every(url => typeof url === 'string'))) {
throw new MER_ERR_INVALID_OPTS('gateway: all "services" must have an "url" String, or a non-empty Array of String, property')
}
}
}
if (Array.isArray(schema)) {

@@ -156,0 +175,0 @@ schema = schema.join('\n')

2

package.json
{
"name": "mercurius",
"version": "9.4.0",
"version": "9.5.0",
"description": "Fastify GraphQL adapter with gateway and subscription support",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -62,1 +62,146 @@ 'use strict'

})
test('Each "gateway" option "services" must be an object', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
'foo'
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must be objects')
}
})
test('Each "gateway" option "services" must have a "name"', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{}
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have a "name" String property')
}
})
test('Each "gateway" option "services" must have a "name" that is a String', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 42 }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have a "name" String property')
}
})
test('Each "gateway" option "services" must have a "name" that is unique', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 'foo', url: 'https://foo' },
{ name: 'foo' }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have a unique "name": "foo" is already used')
}
})
test('Each "gateway" option "services" must have an "url"', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 'foo' }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have an "url" String, or a non-empty Array of String, property')
}
})
test('Each "gateway" option "services" must have an "url" that is a String or an Array', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 'foo', url: new URL('https://foo') }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have an "url" String, or a non-empty Array of String, property')
}
})
test('Each "gateway" option "services" must have an "url" that, if it is an Array, should not be empty', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 'foo', url: [] }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have an "url" String, or a non-empty Array of String, property')
}
})
test('Each "gateway" option "services" must have an "url" that, if it is a non-empty Array, should be filled with Strings only', async (t) => {
const app = Fastify()
app.register(GQL, {
gateway: {
services: [
{ name: 'foo', url: [new URL('https://foo')] }
]
}
})
try {
await app.ready()
} catch (err) {
t.equal(err.message, 'Invalid options: gateway: all "services" must have an "url" String, or a non-empty Array of String, property')
}
})

Sorry, the diff of this file is not supported yet

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