@apollo-model/federation
TypeScript icon, indicating that this package has built-in type declarations

0.11.7-alpha.1 • 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 @apollo-model/federation

Weekly Downloads

2

Version

0.11.7-alpha.1

License

SEE LICENSE IN LICENSE.md

Unpacked Size

572 kB

Total Files

275

Last publish

Collaborators

  • vitramir