New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nexus-federation-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus-federation-plugin

A [Nexus](https://nexusjs.org/) plugin to integrate [Apollo Federation](https://www.apollographql.com/docs/federation/) with [Nexus Schema](https://nexusjs.org/docs/guides/schema).

  • 0.0.12
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
9
Maintainers
1
Weekly downloads
 
Created
Source

nexus-federation-plugin

A Nexus plugin to integrate Apollo Federation with Nexus Schema.

Install

yarn add nexus-federation-plugin
or
npm i nexus-federation-plugin

API

nexus plugin
import { makeSchema } from 'nexus'
import { nexusPluginFederation } from 'nexus-federation-plugin'

export const nexusSchema = makeSchema({
  types,
  plugins: [nexusPluginFederation], // add plugin here
  outputs: {
    schema: __dirname + '/generated/schema.graphql',
    typegen: __dirname + '/generated/nexus.ts',
  },
  contextType: {
    module: join(__dirname, 'context.ts'),
    export: 'Context',
  },
})
Transform nexus schema to Federation
import { ApolloServer } from 'apollo-server'
import {
  transformSchemaFederation,
  printTransformedSchema,
} from 'nexus-federation-plugin'

import { createContext } from './context'
import { nexusSchema } from './nexusSchema'

const server = new ApolloServer({
  // warp nexus schema with our function
  schema: transformSchemaFederation(nexusSchema),
  context: createContext,
})

server.listen().then(({ url }) => {
  // you can print Transformed Schema with our function
  // it's take two args
  // 1- server instance
  // 2- create file path default `src/generated`
  printTransformedSchema(server)
  console.log(`🚀  Server ready at ${url}`)
})

Usage

Like graphql-transform-federation you can pass configration to nexus objectType

import { objectType } from 'nexus'

export const User = objectType({
  name: 'User',
  keyFields: ['id'],
  fieldDirectives: {
    id: {
      external: true,
      requires: 'email name',
    },
    email: {
      external: true,
    },
  },
  resolveReference: (parent, ctx) => {},
  definition(t) {
    t.nonNull.int('id')
    t.nonNull.string('email')
    t.string('name')
  },
})

FAQs

Package last updated on 15 Jan 2021

Did you know?

Socket

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.

Install

Related posts

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