JSPM

  • Created
  • Published
  • Downloads 262594
  • Score
    100M100P100Q102648F
  • License SEE LICENSE IN LICENSE.md

Apollo Federation Utilities

Package Exports

  • @apollo/federation
  • @apollo/federation/dist/composition
  • @apollo/federation/dist/directives
  • @apollo/federation/dist/types

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@apollo/federation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 }])
});