https://github.com/getstation/apollo-link-reactive-schema
Apollo Link that provides a reactive-graphql execution environment to perform operations on a provided reactive schema
https://github.com/getstation/apollo-link-reactive-schema
Last synced: about 1 year ago
JSON representation
Apollo Link that provides a reactive-graphql execution environment to perform operations on a provided reactive schema
- Host: GitHub
- URL: https://github.com/getstation/apollo-link-reactive-schema
- Owner: getstation
- Created: 2019-01-19T01:29:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-11T17:08:42.000Z (over 6 years ago)
- Last Synced: 2025-04-19T10:32:16.192Z (about 1 year ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# apollo-link-reactive-schema
[](https://badge.fury.io/js/apollo-link-reactive-schema)
> Apollo Link that provides a [reactive-graphql execution environment](https://github.com/mesosphere/reactive-graphql) to perform operations on a provided reactive schema.
## Installation
`npm install apollo-link-reactive-schema --save`
## Usage
```js
import { ApolloClient } from 'apollo-client';
import { from } from 'rxjs';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ReactiveSchemaLink } from 'apollo-link-reactive-schema';
import { gql } from 'graphql-tag';
import schema from './path/to/your/schema';
const graphqlClient = new ApolloClient({
cache: new InMemoryCache(),
link: new ReactiveSchemaLink({ schema }),
});
const query = gql`
# don't forget the @live directive, otherwise you'll experience
# difficulties with subscription>unsubscription>subscription
query @live {
someReactiveField
}
`;
const $res = graphqlClient.watchQuery({ query });
$res.subscribe(res => console.log(res));
```
### Options
The `ReactiveSchemaLink` constructor can be called with an object with the following properties:
* `schema`: an executable graphql schema
* `context`: an object passed to the resolvers, following the [graphql specification](http://graphql.org/learn/execution/#root-fields-resolvers) or a function that accepts the operation and returns the resolver context.