https://github.com/getstation/apollo-link-electron-ipc
Apollo link that transfers operations to main
https://github.com/getstation/apollo-link-electron-ipc
Last synced: 7 months ago
JSON representation
Apollo link that transfers operations to main
- Host: GitHub
- URL: https://github.com/getstation/apollo-link-electron-ipc
- Owner: getstation
- Created: 2018-02-02T18:44:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-23T23:25:59.000Z (over 7 years ago)
- Last Synced: 2025-01-19T21:15:46.920Z (over 1 year ago)
- Language: TypeScript
- Size: 53.7 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# apollo-link-electron-ipc
> In electron, forward GraqhQL operations to the main process
[![NPM Version][npm-image]][npm-url]
## Install
```bash
npm i -S apollo-link-electron-ipc
```
## Usage
```ts
// in main
import { createElectronRPCGraphQLRequestExecutor } from 'apollo-link-electron-ipc';
import { HttpLink } from 'apollo-link-http';
import fetch from 'electron-fetch';
// example with HttpLink
createElectronRPCGraphQLRequestExecutor({
link: new HttpLink({
uri: 'your-endpoint',
fetch
})
});
// in renderer
import { createElectronRPCLink } from 'apollo-link-electron-ipc';
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
const client = new ApolloClient({
link: createElectronRPCLink(),
cache: new InMemoryCache(),
});
client.query(MY_QUERY);
```
### Streaming link
⚠️ apollo-link-electron-ipc supports `ObservableQueries` with streaming links, but requires to instantiate `ApolloClient` with option `queryDeduplication: false,`. See [apollographql/apollo-client#4322](https://github.com/apollographql/apollo-client/issues/4322)
## License
[MIT](http://mit-license.org)
[npm-image]: https://img.shields.io/npm/v/apollo-link-electron-ipc.svg
[npm-url]: https://npmjs.org/package/apollo-link-electron-ipc