This application integrates the following technologies:
- Apollo Client 2.0 to communicate with GraphQL Server
- graphcool providing the GraphQL Server
- Angular CLI version 1.5.0
You can add todos and toggle their status. If you open different windows each will be updated accordingly.
If you have any questions feel free to ping me on @gerardsans.
First, clone the repo via git:
$ git clone https://github.com/gsans/todo-apollo-v2.gitAnd then install dependencies:
$ cd todo-apollo-v2 && npm iIn order to run this project you need to create the data model (schema) below using graphcool console online or graphcool CLI.
This is the schema used
type Todo @model {
id: ID! @isUnique
text: String!
complete: Boolean!
}Create a GraphQL Server using this schema and graphcool CLI. On the todo-apollo-v2 folder run the following commands:
$ npm install -g graphcool
$ graphcool push
$ graphcool endpointsEdit /src/app/graphql.module.ts and replace ADD_YOUR_API_KEY_HERE with the endpoints from the previous step.
private setupLink() {
// queries and mutations link (http)
const http = this.httpLink.create({
uri: 'https://api.graph.cool/simple/v1/ADD_YOUR_API_KEY_HERE'
});
// subscriptions link (websockets)
const websocket = new WebSocketLink(
new SubscriptionClient('wss://subscriptions.graph.cool/v1/ADD_YOUR_API_KEY_HERE', {
reconnect: true
})
);$ ng serveNavigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Note: requires a node version >=6.x
MIT © Gerard Sans


