{"name":"@apollo/subgraph","version":"2.13.0-preview.0","keywords":["graphql","federation","apollo","subgraph"],"author":{"name":"Apollo","email":"packages@apollographql.com"},"license":"MIT","_id":"@apollo/subgraph@2.13.0-preview.0","maintainers":[{"name":"duckki-apollo","email":"duckki.oe@apollographql.com"},{"name":"apollo-bot","email":"npm@apollographql.com"}],"homepage":"https://github.com/apollographql/federation#readme","bugs":{"url":"https://github.com/apollographql/federation/issues"},"dist":{"shasum":"ee5da1fd57ad733627d0e10c74f62e836abaa946","tarball":"http://registry-npm.ywwl.com/@apollo/subgraph/download/@apollo/subgraph-2.13.0-preview.0.tgz","fileCount":58,"integrity":"sha512-xC9Uqp8J97wlwh9ypPbSCxWAqlRYXZRcCfOBmkbXI5BathndNxDHP7I2jSAOL6R5e9xpLsmvZ5ouMiOZezPrEQ==","signatures":[{"sig":"MEYCIQCxHk92EmV6tK2ndgkLggJCjyIuPcnTuJQ8GnHEQ8yofAIhAI8yl0+RKWMz/GeBF5AOrWV7g67EFJE0Ka64hQwdvdQA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":124794,"size":30706,"noattachment":false,"key":"/@apollo/subgraph/-/@apollo/subgraph-2.13.0-preview.0.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14.15.0"},"gitHead":"bda422b9e98aa10f0dc672a5c44c0037c4797171","_npmUser":{"name":"apollo-bot","email":"npm@apollographql.com"},"repository":{"url":"git+https://github.com/apollographql/federation.git","type":"git","directory":"subgraph-js/"},"_npmVersion":"8.19.4","description":"Apollo Subgraph Utilities","directories":{},"_nodeVersion":"16.20.2","dependencies":{"@apollo/cache-control-types":"^1.0.2","@apollo/federation-internals":"2.13.0-preview.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","peerDependencies":{"graphql":"^16.5.0"},"_npmOperationalInternal":{"tmp":"tmp/subgraph_2.13.0-preview.0_1763156980209_0.45661985721855314","host":"s3://npm-registry-packages-npm-production"},"readme":"[![Continuous Integration](https://github.com/apollographql/subgraph-js/workflows/Continuous%20Integration/badge.svg)](https://github.com/apollographql/subgraph-js/actions?query=workflow%3A%22Continuous+Integration%22)\n[![MIT License](https://img.shields.io/github/license/apollographql/subgraph-js.svg)](LICENSE)\n[![NPM](https://img.shields.io/npm/v/%40apollo%2Fsubgraph)](https://www.npmjs.com/package/@apollo/subgraph)\n[![Join the community forum](https://img.shields.io/badge/join%20the%20community-forum-blueviolet)](https://community.apollographql.com)\n\n# @apollo/subgraph\n\nApollo Federation subgraph utilities for the `graphql-js` ecosystem.\n\n`@apollo/subgraph` is built on top of `graphql-js` and provides transformation logic\nto make your GraphQL schemas Federation compatible. `buildSubgraphSchema` adds common\nFederation type definition (e.g. `Any` scalar, `_Entity` union, Federation directives, \netc) and allows you to easily specify your Federated entity resolvers.\n\n## Installation\n\nRequires Node.js 22 or later.\n\n```sh\nnpm install @apollo/subgraph graphql\n```\n\n## Usage\n\n```ts\nimport { ApolloServer } from '@apollo/server';\nimport { startStandaloneServer } from '@apollo/server/standalone';\nimport { buildSubgraphSchema } from '@apollo/subgraph';\nimport gql from 'graphql-tag';\n\nconst typeDefs = gql`\n  extend schema\n    @link(url: \"https://specs.apollo.dev/federation/v2.9\", import: [\"@key\"])\n\n  type Query {\n    product(id: ID!): Product\n  }\n\n  type Product @key(fields: \"id\") {\n    id: ID!\n    name: String\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    product: (_source, { id }) => products.find((product) => product.id === id),\n  },\n  Product: {\n    // Called for each entity representation the router sends to `_entities`.\n    __resolveReference: (reference) =>\n      products.find((product) => product.id === reference.id),\n  },\n};\n\nconst server = new ApolloServer({\n  schema: buildSubgraphSchema([{ typeDefs, resolvers }]),\n});\n\nawait startStandaloneServer(server, { listen: { port: 4001 } });\n```\n\n### API\n\n- **`buildSubgraphSchema(modulesOrSDL)`** — builds the executable subgraph schema.\n  Accepts a `DocumentNode`, or an array of documents or `{ typeDefs, resolvers }`\n  modules.\n- **`printSubgraphSchema(schema)`** — prints the complete subgraph schema,\n  federation directives and types included.\n- **`addResolversToSchema(schema, resolvers)`** — attaches a resolver map to an\n  existing schema, understanding `__resolveReference` alongside the usual\n  `__resolveType` / `__isTypeOf`.\n- **`entitiesResolver({ representations, context, info })`** — the `_entities`\n  resolver, exported for libraries that assemble their own root fields.\n\nEntity references are resolved through `__resolveReference`, either from a\nresolver map or from `extensions.apollo.subgraph.resolveReference` on the type.\n\n## Development\n\n```sh\nnpm install\nnpm run build\nnpm test\n```\n\nThe [`compatibility/`](./compatibility) workspace runs the\n[Apollo Federation subgraph compatibility suite](https://github.com/apollographql/apollo-federation-subgraph-compatibility)\nagainst this library, using docker compose for the router and reference subgraphs. \nSee its [README](./compatibility/README.md).\n\n```sh\nnpm run compatibility --workspace @apollo/subgraph-compatibility\n```\n\n## Contact\n\nIf you have a specific question about the library or code, please start a discussion in the [Apollo community forums](https://community.apollographql.com/).\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\nAfter you have your local branch set up, take a look at our open issues to see where you can contribute.\n\n## Security\n\nFor more info on how to contact the team for security issues, see our [Security Policy](https://github.com/apollographql/federation-jvm/security/policy).\n\n## License\n\nThis library is licensed under [The MIT License (MIT)](LICENSE).\n","publish_time":1763156980450,"_cnpm_publish_time":1763156980450,"dist-tags":{"alpha":"2.10.0-alpha.4","beta":"2.9.0-beta.0","connectors":"2.9.0-connectors.9","latest":"2.10.0","latest-1":"0.6.1","next":"2.11.0-preview.0","preview":"2.11.0-preview.0","testing":"2.7.4-testing.1"}}