https://github.com/react-native-training/apollo-subscriptions-book-club
Book Aggregation App using Apollo + GraphCool Subcriptions
https://github.com/react-native-training/apollo-subscriptions-book-club
Last synced: about 1 year ago
JSON representation
Book Aggregation App using Apollo + GraphCool Subcriptions
- Host: GitHub
- URL: https://github.com/react-native-training/apollo-subscriptions-book-club
- Owner: react-native-training
- Created: 2017-06-22T22:15:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-26T23:53:20.000Z (almost 9 years ago)
- Last Synced: 2025-04-25T21:16:51.009Z (about 1 year ago)
- Language: JavaScript
- Size: 686 KB
- Stars: 53
- Watchers: 7
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Apollo + Graphcool Subscription Book App

### To get started:
1. Clone the repository
```
git clone https://github.com/dabit3/apollo-subscriptions-book-club.git
```
2. `cd` into directory
```
cd apollo-subscriptions-book-club
```
3. Install dependencies
```
yarn
# or npm install
```
4. Install [Graphcool CLI](https://github.com/graphcool/graphcool-cli)
```
npm install -g graphcool
```
5. Create GraphQL server
```
graphcool init --schema ./schema.graphql --name BookClub
```
From the terminal output, you need to grab the project ID and use it in the next step. This ID is also available in the generated [project file](https://www.graph.cool/docs/reference/cli/project-files-ow2yei7mew/) `project.graphcool`.

> **Note:** If you need to find out the available endpoints for your project, you can simply use the `graphcool endpoints` command (in the directory where `project.graphcool` is located) or grab them from the [Graphcool Console](https://console.graph.cool).
6. Configure endpoints
Open `app/index.js` and set the `projectId` variable to your project ID from the previous step. The project ID will be used to configure the endpoints for the GraphQL API as well as for the subscriptions:
```js
// Add your own project ID here
const projectId = '__YOUR_PROJECT_ID__'
// Endpoint for the Subscriptions API
const wsClient = new SubscriptionClient(`wss://subscriptions.graph.cool/v1/${projectId}`, {
reconnect: true
});
// Endpoint for the regular GraphQL API
const networkInterface = createNetworkInterface({
uri: `https://api.graph.cool/simple/v1/${projectId}`
});
```