nevisor-federation
TypeScript icon, indicating that this package has built-in type declarations

0.10.2 • Public • Published

Apollo Federation Utilities

This package provides utilities for creating GraphQL microservices, which can be combined into a single endpoint through tools like Apollo Gateway.

For complete documentation, see the Apollo Federation API reference.

Usage

const { ApolloServer, gql } = require("apollo-server");
const { buildFederatedSchema } = require("@apollo/federation");

const typeDefs = gql`
  type Query {
    me: User
  }

  type User @key(fields: "id") {
    id: ID!
    username: String
  }
`;

const resolvers = {
  Query: {
    me() {
      return { id: "1", username: "@ava" }
    }
  },
  User: {
    __resolveReference(user, { fetchUserById }){
      return fetchUserById(user.id)
    }
  }
};

const server = new ApolloServer({
  schema: buildFederatedSchema([{ typeDefs, resolvers }])
});

Readme

Keywords

none

Package Sidebar

Install

npm i nevisor-federation

Weekly Downloads

1

Version

0.10.2

License

SEE LICENSE IN LICENSE.md

Unpacked Size

531 kB

Total Files

262

Last publish

Collaborators

  • nicoosokhan