{"id":20942207,"url":"https://github.com/getstation/apollo-link-webextensions-messaging","last_synced_at":"2025-10-03T21:08:24.982Z","repository":{"id":40793866,"uuid":"241681207","full_name":"getstation/apollo-link-webextensions-messaging","owner":"getstation","description":"Apollo Link that, in a WebExtension, forwards GraphQL operations between processes","archived":false,"fork":false,"pushed_at":"2023-03-02T20:26:43.000Z","size":904,"stargazers_count":9,"open_issues_count":7,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-14T00:10:13.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/getstation.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":"2020-02-19T17:33:25.000Z","updated_at":"2021-10-07T15:20:36.000Z","dependencies_parsed_at":"2024-11-18T23:32:39.326Z","dependency_job_id":"0523f329-1e7e-466c-8f63-a1d244b2d139","html_url":"https://github.com/getstation/apollo-link-webextensions-messaging","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/getstation/apollo-link-webextensions-messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Fapollo-link-webextensions-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Fapollo-link-webextensions-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Fapollo-link-webextensions-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Fapollo-link-webextensions-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getstation","download_url":"https://codeload.github.com/getstation/apollo-link-webextensions-messaging/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Fapollo-link-webextensions-messaging/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263778557,"owners_count":23510016,"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":[],"created_at":"2024-11-18T23:24:30.385Z","updated_at":"2025-10-03T21:08:24.893Z","avatar_url":"https://github.com/getstation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apollo-link-webextensions-messaging\n\n\u003e Apollo link that, in a WebExtension, forwards GraphQL operations between processes\n\n[![NPM Version][npm-image]][npm-url]\n\n\n## Install\n\n```bash\nnpm i -S apollo-link-webextensions-messaging\n```\n\n## Features\n- Supports response streaming. Perfect to use with [`reactive-graphql`][reactive-graphql] and [`apollo-link-reactive-schema`][apollo-link-reactive-schema]\n- Compatible with Chrome Extensions and Web Extensions APIs\n- Independent of `Port` creation method: adaptable for cross-extension messaging or native messaging\n- Messaging context passing: use messaging `Port` (and esp. `MessageSender`) in local GraphQL resolvers\n\n## Usage\n\n```ts\n// ------------------\n// in background page\nimport { createWebExtensionMessagingExecutorListener } from 'apollo-link-webextensions-messaging';\nimport { SchemaLink } from 'apollo-link-schema';\nimport schema from './path/to/your/schema';\n\n// local schema execution\nconst link = new SchemaLink({\n  schema,\n  context: operation =\u003e ({\n    // `createWebExtensionMessagingExecutorListener` will\n    // add `port`, the `onConnect`'s `Port` as Operation's context\n    // we extract the `MessageSender` into GQL's context so that\n    // it can be used in resolvers\n    sender: operation.getContext().port.sender,\n  })\n});\n\nconst listener = createWebExtensionMessagingExecutorListener({\n  link,\n});\n\nchrome.runtime.onConnect.addListener(listener);\n\n\n// ----------------\n// in content script\nimport { createWebExtensionsMessagingLink } from 'apollo-link-webextensions-messaging';\nimport { ApolloClient } from 'apollo-client';\nimport { InMemoryCache } from 'apollo-cache-inmemory';\n\nconst port = chrome.runtime.connect();\n\nconst client = new ApolloClient({\n  // can also be `createWebExtensionsMessagingLink((operation) =\u003e port)`\n  link: createWebExtensionsMessagingLink(port),\n  cache: new InMemoryCache(),\n  // from experience, if `queryDeduplication` is true,\n  // `client.watchQuery` unsubscription will not be\n  // properly passed down to the `link`\n  queryDeduplication: false,\n});\n\nclient.query(MY_QUERY);\n```\n\n## License\n\n[MIT](http://mit-license.org)\n\n[npm-image]: https://img.shields.io/npm/v/apollo-link-webextensions-messaging.svg\n[npm-url]: https://npmjs.org/package/apollo-link-webextensions-messaging\n[reactive-graphql]: https://github.com/mesosphere/reactive-graphql\n[apollo-link-reactive-schema]: https://github.com/getstation/apollo-link-reactive-schema","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetstation%2Fapollo-link-webextensions-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetstation%2Fapollo-link-webextensions-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetstation%2Fapollo-link-webextensions-messaging/lists"}