https://github.com/johnnynotsolucky/cycle-apollo
Apollo GraphQL driver for Cycle.js
https://github.com/johnnynotsolucky/cycle-apollo
apollo cyclejs
Last synced: 9 months ago
JSON representation
Apollo GraphQL driver for Cycle.js
- Host: GitHub
- URL: https://github.com/johnnynotsolucky/cycle-apollo
- Owner: johnnynotsolucky
- License: apache-2.0
- Created: 2017-04-19T07:30:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T15:06:22.000Z (almost 8 years ago)
- Last Synced: 2025-08-04T06:46:04.272Z (11 months ago)
- Topics: apollo, cyclejs
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cycle-apollo
## Usage
### Installation
```
npm install cycle-apollo
```
### Example
```
const main = ({ DOM, Apollo }) => {
const query$ = xs.of({
query: gql`
query usersList {
allUsers {
id,
name
}
}`,
category: 'allusers'
})
const results$ = Apollo.select('allusers')
.flatten()
.startWith([])
const vdom$ = results$
.map(users =>
ul(users.map(user => li(user.name)))
)
return {
DOM: vdom$,
Apollo: query$
}
}
const networkInterface = createNetworkInterface({
uri: process.env.GRAPHQL_ENDPOINT
})
const client = new ApolloClient({ networkInterface })
run(main, {
DOM: makeDOMDriver('#app'),
Apollo: makeApolloDriver(client)
})
```
## Development
### Demo
```
npm run graphql
npm run dev
```
The demo uses [graphql-up](https://graph.cool/graphql-up/) to create a backend on Graphcool. Therefore, you only need to run
`graphql` once, or when the endpoint has expired.
### Build
#### Node Module
```
make lib
```
#### Browser
```
make dist
```