{"id":15569616,"url":"https://github.com/patrick91/federation-merge","last_synced_at":"2026-06-08T01:01:31.789Z","repository":{"id":237448153,"uuid":"725129943","full_name":"patrick91/federation-merge","owner":"patrick91","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-29T13:57:30.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T02:22:11.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrick91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-29T13:57:28.000Z","updated_at":"2025-02-21T16:48:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"478ae969-4a45-4ad8-a336-e4eb3c2371d3","html_url":"https://github.com/patrick91/federation-merge","commit_stats":null,"previous_names":["patrick91/federation-merge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/patrick91/federation-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick91%2Ffederation-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick91%2Ffederation-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick91%2Ffederation-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick91%2Ffederation-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrick91","download_url":"https://codeload.github.com/patrick91/federation-merge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick91%2Ffederation-merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T17:33:57.375Z","updated_at":"2026-06-08T01:01:31.768Z","avatar_url":"https://github.com/patrick91.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to run this example\n\n## Install dependencies\n\nin each frame folder run\n\n```bash\npdm install\n```\n\nAnd also run\n\n```bash\ncurl -sSL https://rover.apollo.dev/nix/latest | sh\n```\n\nTo install rover\n\n## Run the services\n\nin each frame folder run\n\n```bash\npdm dev\n```\n\n## Run Apollo Router in dev mode\n\nin the root folder run\n\n```bash\nrover dev --supergraph-config supergraph.yaml\n```\n\nThen you should be able to access the Apollo Studio Explorer at\nhttp://localhost:4000\n\n## Queries:\n\n\u003e standard federation query, field with the same name will only be fetched once\n\u003e usually from the first service\n\n```graphql\nquery Basic($id: ID!) {\n  frame(id: $id) {\n    id\n\n    # unique fields will come from the correct service\n    # (because they only live in that specific service)\n    # for example:\n    frameFord {\n      id\n      dataOnlyInFrameB\n    }\n\n    frameGpl {\n      id\n      dataOnlyInFrameA\n    }\n  }\n}\n```\n\n\u003e similar to the one we had previously, but also with a common field, the common\n\u003e field will be resolved by only one subgraph\n\n```graphql\nquery CommonField($id: ID!) {\n  frameWithAdditionalData(id: $id) {\n    id\n    commonField\n    # try commenting one of these two fields\n    # and see the value of common field update\n    # Apollo Router tries to do the most efficient\n    # query plan, in order to reduce the number of\n    # data fetches\n    dataOnlyInFrameA\n    dataOnlyInFrameB\n  }\n}\n```\n\n\u003e in this approach we abuse some feature of federation in order to fetch the\n\u003e data from the correct subgraph in the frame field for the `FrameWithRequires`\n\u003e type we require the `available_X` field (using the @require directive) for\n\u003e every subgraph, so that we have a way of knowing if this frame is available in\n\u003e any of the frames subgraphs the annoying part of this is that we need to\n\u003e implement this field in all the subgraphs, and we also need some logic in our\n\u003e main Frame service to return the right type we also use an interface to make\n\u003e common fields easier to fetch\n\n```graphql\nquery FrameWithRequires($id: ID!) {\n  frameWithRequires(id: $id) {\n    id\n    frame {\n      id\n      name\n\n      ... on FrameA {\n        dataOnlyInFrameA\n      }\n\n      ... on FrameB {\n        dataOnlyInFrameB\n      }\n    }\n  }\n}\n```\n\n\u003e similar to the one before, but we assume the main Frame service has a way to\n\u003e know where the data comes from, in this case we only do a simple check on the\n\u003e id if the id is one then we return data from Frame A otherwise Frame B we can\n\u003e also add interfaces like above to make it easier to fetch\n\n```graphql\nquery FrameWithUnion($id: ID!) {\n  frameWithUnion(id: $id) {\n    ... on FrameA {\n      dataOnlyInFrameA\n      id\n      name\n    }\n    ... on FrameB {\n      dataOnlyInFrameB\n      id\n      name\n    }\n  }\n}\n```\n\n\u003e this uses service to service communication to fetch the data from other\n\u003e subgraphs I've done a JSON field for time sake, but you can return any object\n\u003e too\n\n```graphql\nquery Http($id: ID!) {\n  frameViaHttp(id: $id)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick91%2Ffederation-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrick91%2Ffederation-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick91%2Ffederation-merge/lists"}