{"_id":"@craft.co/graphql-transform-federation-v2","_rev":"2-f6b4d7881302fef358c87a407e43fe21","name":"@craft.co/graphql-transform-federation-v2","dist-tags":{"latest":"2.2.2"},"versions":{"2.2.0":{"name":"@craft.co/graphql-transform-federation-v2","version":"2.2.0","description":"Add GraphQL federation to an existing GraphQL schema","main":"dist/transform-federation.js","types":"dist/transform-federation.d.ts","scripts":{"test":"jest","test:watch":"npm run test -- --watch","format":"prettier --check '**/*.{js,ts,json,md}'","format:fix":"prettier --write '**/*.{js,ts,json,md}'","example:watch":"nodemon --signal SIGINT -e ts,js -x npm run example","example":"concurrently 'npm run example:gateway' 'npm run example:transformed-server' 'npm run example:federation-server'","example:gateway":"wait-on tcp:4001 && wait-on tcp:4002 && ts-node example/gateway","example:transformed-server":"ts-node example/transformed-server","example:federation-server":"ts-node example/federation-server","prebuild":"rimraf dist","build":"tsc","prepublishOnly":"npm run format && npm run test && npm run build"},"keywords":[],"author":{"name":"Ruben Oostinga"},"repository":{"type":"git","url":"git+https://github.com/janhelleman/graphql-transform-federation-v2.git"},"license":"ISC","devDependencies":{"@apollo/gateway":"^2.1.3","@apollo/subgraph":"^2.1.3","@graphql-tools/delegate":"^9.0.8","@graphql-tools/schema":"^9.0.4","@graphql-tools/utils":"^8.12.0","@types/dedent":"^0.7.0","@types/graphql":"^14.5.0","@types/jest":"^26.0.15","@types/node":"^14.18.31","apollo-server":"^3.10.2","dedent":"^0.7.0","graphql":"^16.5.0","jest":"^26.6.3","nodemon":"^2.0.6","prettier":"^2.2.0","ts-jest":"^26.4.4","ts-node":"^10.8.1","typescript":"^4.1.2","wait-on":"^5.2.0"},"peerDependencies":{"@apollo/federation":"0","graphql":"^16.5.0"},"dependencies":{"@graphql-tools/utils":"^8.12.0"},"bugs":{"url":"https://github.com/janhelleman/graphql-transform-federation-v2/issues"},"homepage":"https://github.com/janhelleman/graphql-transform-federation-v2#readme","directories":{"example":"example"},"gitHead":"4ff78d92d1831290e56ba61df1b8613e6e762e33","_id":"@craft.co/graphql-transform-federation-v2@2.2.0","_nodeVersion":"14.21.3","_npmVersion":"6.14.18","dist":{"integrity":"sha512-xPlebP++bc9F/X/bgdAgcEM+wzyywxXfWKLvl9Oxs542TK+l8fahtbumLwcF5puF2Gzkut/o1DlgZnJORdKR1A==","shasum":"3101d56f167070fb70dd5b48bce2663c07b79490","tarball":"https://registry.npmjs.org/@craft.co/graphql-transform-federation-v2/-/graphql-transform-federation-v2-2.2.0.tgz","fileCount":22,"unpackedSize":58933,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEdDY/k0Lwp5AwtkLrx3QpZLQYQ9EorCrNNZRor1IpSeAiEA4T1786HoVypMriiv5dlMBnZY/C8nNl7Lk2Zq0pkBZjg="}]},"_npmUser":{"name":"rw.craft","email":"ryan.williams@craft.co"},"maintainers":[{"name":"rw.craft","email":"ryan.williams@craft.co"},{"name":"mikejansen","email":"mike.jansen@craft.co"},{"name":"ic.craft","email":"ivan.charapanau@craft.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-transform-federation-v2_2.2.0_1715259565326_0.9318916186341826"},"_hasShrinkwrap":false},"2.2.1":{"name":"@craft.co/graphql-transform-federation-v2","version":"2.2.1","description":"Add GraphQL federation to an existing GraphQL schema","main":"dist/transform-federation.js","types":"dist/transform-federation.d.ts","scripts":{"test":"jest","test:watch":"npm run test -- --watch","format":"prettier --check '**/*.{js,ts,json,md}'","format:fix":"prettier --write '**/*.{js,ts,json,md}'","example:watch":"nodemon --signal SIGINT -e ts,js -x npm run example","example":"concurrently 'npm run example:gateway' 'npm run example:transformed-server' 'npm run example:federation-server'","example:gateway":"wait-on tcp:4001 && wait-on tcp:4002 && ts-node example/gateway","example:transformed-server":"ts-node example/transformed-server","example:federation-server":"ts-node example/federation-server","prebuild":"rimraf dist","build":"tsc","prepublishOnly":"npm run format && npm run test && npm run build"},"keywords":[],"author":{"name":"Ruben Oostinga"},"repository":{"type":"git","url":"git+https://github.com/janhelleman/graphql-transform-federation-v2.git"},"license":"ISC","devDependencies":{"@apollo/gateway":"^2.1.3","@apollo/subgraph":"^2.7.6","@graphql-tools/delegate":"^9.0.8","@graphql-tools/schema":"^9.0.4","@graphql-tools/utils":"^8.12.0","@types/dedent":"^0.7.0","@types/graphql":"^14.5.0","@types/jest":"^26.0.15","@types/node":"^14.18.31","apollo-server":"^3.10.2","concurrently":"^8.2.2","dedent":"^0.7.0","graphql":"^16.5.0","jest":"^26.6.3","nodemon":"^2.0.6","prettier":"^2.2.0","ts-jest":"^26.4.4","ts-node":"^10.8.1","typescript":"^4.1.2","wait-on":"^5.2.0"},"peerDependencies":{"graphql":"^16.5.0"},"dependencies":{"@graphql-tools/utils":"^8.12.0"},"bugs":{"url":"https://github.com/janhelleman/graphql-transform-federation-v2/issues"},"homepage":"https://github.com/janhelleman/graphql-transform-federation-v2#readme","directories":{"example":"example"},"gitHead":"6651daaa2b3cc713d7ad2a8efb84686161c5de90","_id":"@craft.co/graphql-transform-federation-v2@2.2.1","_nodeVersion":"14.21.3","_npmVersion":"6.14.18","dist":{"integrity":"sha512-Ij4gyQ/5IN/aS7WwPDfuJEwm7SypDM0HlnrCwFKYOXfE7rtm6D2qco3ziXFBBtAU8J0dUch6K2aeWF7Y9q/Cjg==","shasum":"147137ab96f318e1b9176e23ade85b5d1e3236c8","tarball":"https://registry.npmjs.org/@craft.co/graphql-transform-federation-v2/-/graphql-transform-federation-v2-2.2.1.tgz","fileCount":22,"unpackedSize":58773,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGOl4pW52jPrD+VGOF4nIsKwrxBX2v9C2WzyvAh2hx6ZAiBNFQHtmAbLdpkQvpGbzSpBYIP4+sKqYOTZ0LCerXKvSw=="}]},"_npmUser":{"name":"rw.craft","email":"ryan.williams@craft.co"},"maintainers":[{"name":"rw.craft","email":"ryan.williams@craft.co"},{"name":"mikejansen","email":"mike.jansen@craft.co"},{"name":"ic.craft","email":"ivan.charapanau@craft.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-transform-federation-v2_2.2.1_1715338817636_0.9529690664166972"},"_hasShrinkwrap":false},"2.2.2":{"name":"@craft.co/graphql-transform-federation-v2","version":"2.2.2","description":"Add GraphQL federation to an existing GraphQL schema","main":"dist/transform-federation.js","types":"dist/transform-federation.d.ts","scripts":{"test":"jest","test:watch":"npm run test -- --watch","format":"prettier --check '**/*.{js,ts,json,md}'","format:fix":"prettier --write '**/*.{js,ts,json,md}'","example:watch":"nodemon --signal SIGINT -e ts,js -x npm run example","example":"concurrently 'npm run example:gateway' 'npm run example:transformed-server' 'npm run example:federation-server'","example:gateway":"wait-on tcp:4001 && wait-on tcp:4002 && ts-node example/gateway","example:transformed-server":"ts-node example/transformed-server","example:federation-server":"ts-node example/federation-server","prebuild":"rimraf dist","build":"tsc","prepublishOnly":"npm run format && npm run test && npm run build"},"keywords":[],"author":{"name":"Ruben Oostinga"},"repository":{"type":"git","url":"git+https://github.com/janhelleman/graphql-transform-federation-v2.git"},"license":"ISC","devDependencies":{"@apollo/gateway":"^2.1.3","@graphql-tools/delegate":"^9.0.8","@graphql-tools/schema":"^9.0.4","@graphql-tools/utils":"^8.12.0","@types/dedent":"^0.7.0","@types/graphql":"^14.5.0","@types/jest":"^26.0.15","@types/node":"^14.18.31","apollo-server":"^3.10.2","concurrently":"^8.2.2","dedent":"^0.7.0","graphql":"^16.5.0","jest":"^26.6.3","nodemon":"^2.0.6","prettier":"^2.2.0","ts-jest":"^26.4.4","ts-node":"^10.8.1","typescript":"^4.1.2","wait-on":"^5.2.0"},"peerDependencies":{"graphql":"^16.5.0"},"dependencies":{"@apollo/subgraph":"^2.7.7","@graphql-tools/utils":"^8.12.0"},"bugs":{"url":"https://github.com/janhelleman/graphql-transform-federation-v2/issues"},"homepage":"https://github.com/janhelleman/graphql-transform-federation-v2#readme","directories":{"example":"example"},"gitHead":"d08d59d01dc8fd917a199519f5ffe167118dcb49","_id":"@craft.co/graphql-transform-federation-v2@2.2.2","_nodeVersion":"14.21.3","_npmVersion":"6.14.18","dist":{"integrity":"sha512-HpOqUzvNH4BJ0E51tfePMb3EcpTw7v6zbwiRYxLzzmQIyJdUlVNryNvIOWEnRVsOdjY05/K04lJcwY7BbjPspw==","shasum":"025a65c3c3658bce7471c784b1eca0faf6fd22e5","tarball":"https://registry.npmjs.org/@craft.co/graphql-transform-federation-v2/-/graphql-transform-federation-v2-2.2.2.tgz","fileCount":22,"unpackedSize":58773,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyIlEUBTF64zftwgRA7I3r9yVhMmP4C8FM87LSgRKNMwIgHN6kqbVcHEsrWOr1YN9W61ZUmCEdgYkNxu6TXy5Fsxs="}]},"_npmUser":{"name":"rw.craft","email":"ryan.williams@craft.co"},"maintainers":[{"name":"rw.craft","email":"ryan.williams@craft.co"},{"name":"mikejansen","email":"mike.jansen@craft.co"},{"name":"ic.craft","email":"ivan.charapanau@craft.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-transform-federation-v2_2.2.2_1715590788238_0.035100049280949897"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-09T12:59:25.202Z","2.2.0":"2024-05-09T12:59:25.457Z","modified":"2024-05-13T08:59:48.625Z","2.2.1":"2024-05-10T11:00:17.795Z","2.2.2":"2024-05-13T08:59:48.408Z"},"maintainers":[{"name":"rw.craft","email":"ryan.williams@craft.co"},{"name":"mikejansen","email":"mike.jansen@craft.co"},{"name":"ic.craft","email":"ivan.charapanau@craft.co"}],"description":"Add GraphQL federation to an existing GraphQL schema","homepage":"https://github.com/janhelleman/graphql-transform-federation-v2#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/janhelleman/graphql-transform-federation-v2.git"},"author":{"name":"Ruben Oostinga"},"bugs":{"url":"https://github.com/janhelleman/graphql-transform-federation-v2/issues"},"license":"ISC","readme":"# graphql-transform-federation-v2\n\nGraphQL schema transform for adding Apollo Federation v2 features. Fork of\njanhelleman/graphql-transform-federation-v2.\n\n# ================ Original README ================\n\nThis is a modified version of\n[graphql-transform-federation](https://github.com/0xR/graphql-transform-federation)\nby user [0xR](https://github.com/0xR). This version is upgraded to use latest\nversions of [@graphql-tools](https://github.com/ardatan/graphql-tools) and\n[@apollo/gateway and @apollo/subgraph](https://github.com/apollographql/federation).\nThis allows you to transform non-federated GraphQL services to GraphQL\nfederation v2. I implemented \"resolvable: false\" feature for @key as an example.\nThere's might still be issues, I haven't had time to test any edge cases. All\ncredits due to 0xR. Code is as-is, pull requests are welcome.\n\n# graphql-transform-federation\n\nIf you want to use\n[GraphQL federation](https://www.apollographql.com/docs/apollo-server/federation/introduction/),\nbut you can't rebuild your current GraphQL schema, you can use this transform to\nadd GraphQL federation functionality to an existing schema. You need this when\nyou are using a managed GraphQL service or a generated schema which doesn't\nsupport federation (yet).\n\nIf you are using apollo-server or another schema builder that supports\nfederation you don't need this transform you should\n[add the federation directives](https://www.apollographql.com/docs/apollo-server/federation/implementing/)\ndirectly.\n\nThis transform will add the resolvers and directives to conform to the\n[federation specification](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#federation-schema-specification).\nMuch of the\n[federation sourcecode](https://github.com/apollographql/apollo-server/tree/master/packages/apollo-federation)\ncould be reused ensuring it is compliant to the specification.\n\nCheck out the\n[blogpost introducing graphql-tranform-federation](https://xebia.com/blog/graphql-federation-for-everyone/)\nfor more background information.\n\n![Architecture diagram for graphql-transform-federation](https://docs.google.com/drawings/d/e/2PACX-1vQkWQKeH9OClskaHoV0XPoVGl-w1_MEFGkhuRW03KG0R3SHXJXv9E4pOF4IR0EnoubS1vn1a_33UAnb/pub?w=990&h=956 'Architecture using a remote schema')\n\n## Usage\n\nYou can use this transform on a local or a remote GraphQL schema. When using a\nremote schema your service acts a middleware layer as shown in the diagram\nabove. Check the\n[remote schema documentation](https://www.apollographql.com/docs/graphql-tools/remote-schemas/)\nfor how to get an executable schema that you can use with this transform.\n\nThe example below shows a configuration where the transformed schema extends an\nexisting schema. It already had a resolver `productById` which is used to relate\nproducts between the two schemas. This example can be started using\n[npm run example](#npm-run-example).\n\n```typescript\nimport { transformSchemaFederation } from 'graphql-transform-federation';\nimport { delegateToSchema } from 'graphql-tools';\n\nconst schemaWithoutFederation = // your existing executable schema\n\nconst federationSchema = transformSchemaFederation(schemaWithoutFederation, {\n  Query: {\n    // Ensure the root queries of this schema show up the combined schema\n    extend: true,\n  },\n  Product: {\n    // extend Product {\n    extend: true,\n    // Product @key(fields: \"id\") {\n    keyFields: ['id'],\n    fields: {\n      // id: Int! @external\n      id: {\n        external: true\n      }\n    },\n    resolveReference({ id }, context, info) {\n      return delegateToSchema({\n        schema: info.schema,\n        operation: 'query',\n        fieldName: 'productById',\n        args: {\n          id,\n        },\n        context,\n        info,\n      });\n    },\n  },\n});\n```\n\nTo allow objects of an existing schema to be extended by other schemas it only\nneeds to get `@key(...)` directives.\n\n```typescript\nconst federationSchema = transformSchemaFederation(schemaWithoutFederation, {\n  Product: {\n    // Product @key(fields: \"id\") {\n    keyFields: ['id'],\n  },\n});\n```\n\n## API reference\n\n```typescript\nimport { GraphQLSchema } from 'graphql';\nimport { GraphQLReferenceResolver } from '@apollo/subgraph/src/schemaExtensions';\n\ninterface FederationFieldConfig {\n  external?: boolean;\n  provides?: string;\n  requires?: string;\n}\n\ninterface FederationFieldsConfig {\n  [fieldName: string]: FederationFieldConfig;\n}\n\ninterface FederationObjectConfig<TContext> {\n  // An array so you can add multiple @key(...) directives\n  keyFields?: string[];\n  extend?: boolean;\n  resolvable?: boolean;\n  resolveReference?: GraphQLReferenceResolver<TContext>;\n  fields?: FederationFieldsConfig;\n}\n\ninterface FederationConfig<TContext> {\n  [objectName: string]: FederationObjectConfig<TContext>;\n}\n\nfunction transformSchemaFederation<TContext>(\n  schema: GraphQLSchema,\n  federationConfig: FederationConfig<TContext>,\n): GraphQLSchema;\n```\n\n## `npm run example`\n\nRuns 2 GraphQL servers and a federation gateway to combine both schemas.\n[Transformed-server](./example/transformed-server.ts) is a regular GraphQL\nschema that is tranformed using this library. The\n[federation-server](example/federation-server.ts) is a federation server which\nis extended by a type defined by the `transformed-server`. The\n[gateway](./example/gateway.ts) combines both schemas using the apollo gateway.\n\n## `npm run example:watch`\n\nRuns the example in watch mode for development.\n\n## `npm run test`\n\nRun the tests\n","readmeFilename":"README.md"}