{"id":19696766,"url":"https://github.com/freshollie/apollo-bus-link","last_synced_at":"2026-05-07T01:09:44.143Z","repository":{"id":91856835,"uuid":"432301195","full_name":"freshollie/apollo-bus-link","owner":"freshollie","description":"An apollo link and server for communication over message bus (Electron, WebWorker)","archived":false,"fork":false,"pushed_at":"2021-12-09T08:58:41.000Z","size":1820,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-10T09:49:18.771Z","etag":null,"topics":["apollo","apollo-link","electron","graphql","webworker"],"latest_commit_sha":null,"homepage":"https://npm.im/package/apollo-bus-link","language":"TypeScript","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/freshollie.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":"2021-11-26T21:06:42.000Z","updated_at":"2022-06-23T16:23:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"c387da3c-7f5e-4697-b03d-a774d778b6e2","html_url":"https://github.com/freshollie/apollo-bus-link","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshollie%2Fapollo-bus-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshollie%2Fapollo-bus-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshollie%2Fapollo-bus-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freshollie%2Fapollo-bus-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freshollie","download_url":"https://codeload.github.com/freshollie/apollo-bus-link/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241007982,"owners_count":19893083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["apollo","apollo-link","electron","graphql","webworker"],"created_at":"2024-11-11T19:36:05.483Z","updated_at":"2025-10-05T18:18:33.082Z","avatar_url":"https://github.com/freshollie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n:trolleybus::busstop: apollo-bus-link :busstop::bus:\n  \u003cp align=\"left\"\u003e\n    \u003cimg height=\"200\" src=\".github/logo.png\" alt=\"Bus stop\"\u003e\n  \u003c/p\u003e\n\u003c/h1\u003e\n\n[![Pipeline status](https://github.com/freshollie/apollo-bus-link/workflows/pipeline/badge.svg)](https://github.com/freshollie/apollo-bus-link/actions)\n[![Coverage](https://codecov.io/gh/freshollie/apollo-bus-link/branch/main/graph/badge.svg?token=Jh3CM5M1oI)](https://codecov.io/gh/freshollie/apollo-bus-link)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n\u003e Your one stop for message bus apollo links\n\n## What is this?\n\nComplex GraphQL based applications may use a separate process to run\nschema execuation.\n\nThis library provides a set of tools which can used to create an ApolloLink\nand a Schema Executor which can communicate across any JS based message bus.\n\nThis library provides pre-written receipes for `electron` and `webworker`'s\n\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"200\" src=\".github/media/electron.png\" alt=\"Electron architecture\"\u003e\n  \u003cimg height=\"200\" src=\".github/media/webworker.png\" alt=\"Webworker architecture\"\u003e\n\u003c/p\u003e\n\n## Features\n\n- API to integrate with any Bus\n- Subscriptions, Queries, and Mutations\n- Built in support for Electron and WebWorker buses\n\n## Usage\n\n\u003cdetails\u003e\n  \u003csummary\u003eElectron :electron:\u003c/summary\u003e\n\nMain\n\n```typescript\nimport {\n  createBusLinkBackend,\n  createSchemaExecutor,\n} from \"apollo-bus-link/core\";\nimport { electronBus } from \"apollo-bus-link/electron\";\nimport { ipcMain } from \"electron\";\n\n// Args come from the link through `.initialiseBackend`\n// You can pass whatever object you want\nexport type Args = {\n  mockedMode: boolean;\n};\n\nconst backend = createBusLinkBackend\u003cArgs\u003e({\n  registerBus: electronBus(mockIpc.ipcMain),\n  createExecutor: (args) =\u003e\n    createSchemaExecutor({\n      // Same API as apollo-server etc\n      schema,\n      context,\n    }),\n});\n// If you want to preiniitalise the backend, this can be done\n// by calling initialise\n// backend.initialise(...)\nbackend.listen();\n```\n\nRenderer\n\n```typescript\nimport { createElectronBusLink, electronBus } from \"apollo-bus-link/electron\";\nimport { ipcRenderer } from \"electron\";\nimport { ApolloClient } from \"@apollo/client/core\";\n\nconst link = createElectronBusLink\u003cArgs\u003e(ipcRenderer);\nawait link.initialiseBackend({ mockedMode: false });\n\nconst client = new ApolloClient({\n  link,\n  ...\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWebWorker :factory_worker:\u003c/summary\u003e\n\nWorker\n\n```typescript\nimport {\n  createBusLinkBackend,\n  createSchemaExecutor,\n} from \"apollo-bus-link/core\";\nimport { webWorkerBus } from \"apollo-bus-link/electron\";\n\n// Args come from the link through `.initialiseBackend`\n// You can pass whatever object you want\nexport type Args = {\n  mockedMode: boolean;\n};\n\nconst backend = createBusLinkBackend\u003cArgs\u003e({\n  registerBus: webWorkerBus(self),\n  createExecutor: (args) =\u003e\n    createSchemaExecutor({\n      schema,\n      context,\n    }),\n});\n\n// If you want to preiniitalise the backend, this can be done\n// by calling initialise\n// backend.initialise(...)\nbackend.listen();\n```\n\nWindow\n\n```typescript\nimport { createWebWorkerBusLink } from \"apollo-bus-link/webworker\";\nimport { ApolloClient } from \"@apollo/client/core\";\n\nconst worker = new Worker(\n  new URL(\"./Worker.ts\", import.meta.url)\n);\n\nconst link = createWebWorkerBusLink\u003cArgs\u003e(worker);\nawait link.initialiseBackend({ mockedMode: false });\n\nconst client = new ApolloClient({\n  link,\n  ...\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCustom\u003c/summary\u003e\n\nBackend\n\n```typescript\nimport {\n  createBusLinkBackend,\n  createSchemaExecutor,\n} from \"apollo-bus-link/core\";\n\nconst backend = createBusLinkBackend\u003cArgs\u003e({\n  registerBus: (request) =\u003e {\n    myMessageBus.onMessage((message) =\u003e\n      // It may be that you need the context of the initial message\n      // to be able to response, hence this being callback hell\n      request(message, (response) =\u003e {\n        myMessageBus.send(response);\n      })\n    );\n  },\n  createExecutor: (args) =\u003e\n    createSchemaExecutor({\n      // Same API as apollo-server etc\n      schema,\n      context,\n    }),\n});\n```\n\nLink\n\n```typescript\nimport { BusLink } from \"apollo-bus-link/core\";\nimport { ApolloClient } from \"@apollo/client/core\";\n\nconst link = new BusLink({\n  requestHandler: (request) =\u003e {\n    myMessageBus.send(request);\n  },\n  registerResponseHandler: (handler) =\u003e {\n    myMessageBus.onMessage((response) =\u003e handler(response));\n  },\n});\nawait link.initialiseBackend({ mockedMode: false });\n\nconst client = new ApolloClient({\n  link,\n  ...\n});\n```\n\n\u003c/details\u003e\n\n## In the wild\n\n- [fresh-configurator](https://github.com/freshollie/fresh-configurator) - Used as both in webworker and electron formats depending on where the app is loaded\n\n## Licence\n\n`MIT`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshollie%2Fapollo-bus-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreshollie%2Fapollo-bus-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshollie%2Fapollo-bus-link/lists"}