{"name":"@apollo/subgraph","version":"2.9.6","keywords":["graphql","federation","apollo","subgraph"],"author":{"name":"Apollo","email":"packages@apollographql.com"},"license":"MIT","_id":"@apollo/subgraph@2.9.6","maintainers":[{"name":"dkuc","email":"dariusz_kuc@hotmail.com"},{"name":"apollo-bot","email":"npm@apollographql.com"},{"name":"phryneas","email":"mail@lenzw.de"},{"name":"abernix","email":"npmjs@jro.cc"}],"homepage":"https://github.com/apollographql/federation#readme","bugs":{"url":"https://github.com/apollographql/federation/issues"},"dist":{"shasum":"8333f44419de6a24e870ec45b7992b02b730d6d1","tarball":"http://registry-npm.ywwl.com/@apollo/subgraph/download/@apollo/subgraph-2.9.6.tgz","fileCount":58,"integrity":"sha512-geU+jKwRSYa/gHzRAKR3JUJt3T7i0Cap46VsnydyewCBuKYzZO4ueUfm522b7VunV7k02CuUeF6TyTBajeKAHQ==","signatures":[{"sig":"MEUCIFVyCvIH/ELwiJXxmmmBn/GSRJ2WdEI4dyMTSiRjol+9AiEAshlDikA8NNcmvqc+9hVqUEY891+XFxrVpG8VhehswBA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":123704,"size":30415,"noattachment":false,"key":"/@apollo/subgraph/-/@apollo/subgraph-2.9.6.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14.15.0"},"gitHead":"f4ef6ebd8de84116ca3bba861f5fb1af3ea0bbf0","_npmUser":{"name":"dkuc","email":"dariusz_kuc@hotmail.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.9.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"graphql":"^16.5.0"},"_npmOperationalInternal":{"tmp":"tmp/subgraph_2.9.6_1773372749928_0.2675531514740108","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":1773372750072,"_cnpm_publish_time":1773372750072,"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"}}