JSPM

@apollo/subgraph

2.12.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 563511
  • Score
    100M100P100Q247998F
  • License MIT

Apollo Subgraph Utilities

Package Exports

  • @apollo/subgraph
  • @apollo/subgraph/dist/directives
  • @apollo/subgraph/dist/directives.js
  • @apollo/subgraph/dist/index.js
  • @apollo/subgraph/dist/printSubgraphSchema
  • @apollo/subgraph/dist/printSubgraphSchema.js
  • @apollo/subgraph/dist/schema-helper
  • @apollo/subgraph/dist/schema-helper/index.js
  • @apollo/subgraph/dist/schema-helper/resolverMap
  • @apollo/subgraph/dist/schema-helper/resolverMap.js
  • @apollo/subgraph/dist/schemaExtensions
  • @apollo/subgraph/dist/schemaExtensions.js
  • @apollo/subgraph/dist/types
  • @apollo/subgraph/dist/types.js
  • @apollo/subgraph/package.json

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/subgraph) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Apollo Subgraph

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 Subgraph API reference.

Usage

import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { gql } from 'graphql-tag';
import { buildSubgraphSchema } from '@apollo/subgraph';

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: buildSubgraphSchema([{ typeDefs, resolvers }])
});

// Note the top-level await!
const { url } = await startStandaloneServer(server);
console.log(`🚀  Server ready at ${url}`);