Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@mercuriusjs/federation
Advanced tools
A module to add Apollo Federation v1 metadata info to a schema.
npm i fastify @mercuriusjs/federation
const Fastify = require('fastify')
const { mercuriusFederationPlugin } = require('@mercuriusjs/federation')
const users = {
1: {
id: '1',
name: 'John',
username: '@john'
},
2: {
id: '2',
name: 'Jane',
username: '@jane'
}
}
const app = Fastify()
const schema = `
extend type Query {
me: User
}
type User @key(fields: "id") {
id: ID!
name: String
username: String
}
`
const resolvers = {
Query: {
me: () => {
return users['1']
}
},
User: {
__resolveReference: (source, args, context, info) => {
return users[source.id]
}
}
}
app.register(mercuriusFederationPlugin, {
schema,
resolvers
})
app.get('/', async function (req, reply) {
const query = '{ _service { sdl } }'
return app.graphql(query)
})
app.listen({ port: 3000 })
mercurius
Instead of using the plugin, the federation schema can be built using the buildFederationSchema
function and passing the schema generated to mercurius
.
const Fastify = require('fastify')
const mercurius = require('mercurius')
const { buildFederationSchema } = require('../')
...
app.register(mercurius, {
schema: buildFederationSchema(schema),
resolvers,
graphiql: true
})
...
A fastify plugin to create a mercurius
server that expose the federation
directives.
const { mercuriusFederationPlugin } = require('@mercuriusjs/federation')
const schema = ...
const resolvers = ...
const app = Fastify()
app.register(mercuriusFederationPlugin, {
schema,
resolvers
})
Uses the same options of mercurius
but
it requires a string
, DocumentNode
or an Array of DocumentNode
for schema
attribute.
Create a schema object that can be used in a federated environment
(schema, opts) => GraphQLSchema
schema
string | DocumentNode | Array: the source schemaopts
object:
isGateway
boolean: If enabled create a schema compatible with the gateway
, Default 'false'FAQs
A plugin for mercurius federation
The npm package @mercuriusjs/federation receives a total of 25,650 weekly downloads. As such, @mercuriusjs/federation popularity was classified as popular.
We found that @mercuriusjs/federation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.