| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Supports all Federation versions. Drop-in replacement for @apollo/composition.
In-browser Federation Playground
# NPM
npm install @theguild/federation-composition
# PNPM
pnpm add @theguild/federation-composition
# Yarn
yarn add @theguild/federation-compositionimport { parse } from "graphql";
import {
composeServices,
compositionHasErrors,
} from "@theguild/federation-composition";
const result = composeServices([
{
name: "users",
typeDefs: parse(/* GraphQL */ `
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key"])
type User @key(fields: "id") {
id: ID!
name: String!
}
type Query {
users: [User]
}
`),
},
{
name: "comments",
typeDefs: parse(/* GraphQL */ `
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.3"
import: ["@key", "@external"]
)
extend type User @key(fields: "id") {
id: ID! @external
comments: [Comment]
}
type Comment {
id: ID!
text: String!
author: User!
}
`),
},
]);
if (compositionHasErrors(result)) {
console.error(result.errors);
} else {
console.log(result.supergraphSdl);
}Install the dependencies:
pnpm installRun the tests:
pnpm testThe lack of a publicly available specification for Apollo Federation, coupled with the non open-source license of the Apollo Composition library, makes it difficult or even impossible to assure complete compatibility of our open-source composition library.
Given that Apollo tools utilize their composition library, there is a potential for conflicting results between our composition library and Apollo's. This may lead to variations in the supergraph, differing composition errors, or, in some cases, conflicting composition outcomes.
We are working to ensure that our composition library is as compatible as possible with Apollo's and will continue to do so as we learn more about the Federation specification.
Your feedback and bug reports are welcome and appreciated.
✅ Done
| Back | FazBrowse Home | New Git URL |