angular-apollo
An API client for the 7digital Apollo platform built for Angular 2 projects.
Last updated 4 years ago by scooper .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install angular-apollo 
SYNC missed versions from official npm registry.

Angular apollo

npm version CircleCI

An API client for the 7digital Apollo platform built for Angular 2 projects.

Installation

npm install angular-apollo

Usage

For a web project:

import { bootstrap }    from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import { ApiService, ListService, Config } from 'angular-apollo';

export class AppComponent {
    constructor(private playlistService:ListService){
        return this.playlistService.findById(10)
            .subscribe((playlist) => {
                this.apolloId = playlist.id;
            }) ;
    };
}

bootstrap(AppComponent, [
    HTTP_PROVIDERS,
    provideApollo({
        baseUrl: 'http://www.example.com'
    })
]);

For an ionic2 project you will need to override the token store:

import { ionicBootstrap } from 'ionic-angular';
import { HTTP_PROVIDERS } from '@angular/http';
import { ApiService, ListService, Config } from 'angular-apollo';

export class AppComponent {
    constructor(private playlistService:ListService){
        return this.playlistService.findById(10)
            .subscribe((playlist) => {
                this.apolloId = playlist.id;
            }) ;
    };
}

ionicBootstrap(AppComponent, [
    provideApollo({
        baseUrl: 'http://www.example.com',
        useTokenStore: () => (
          {provide: TokenStore, useClass: YourCustomTokenStore}
        )
    })
]);

Handling authentication errors

You may want your app to react to failed authentication attempts, in this case, you can register a handler for the token store errors

export class AppComponent {
    constructor(tokenStore:TokenStore){
        tokenStore.events.subscribe(() => {}, () => {
            redirectToLoginPage();
        });
    }

}

Running the tests

Running the E2E tests requires the following environment variables:

TEST_USER_NAME
TEST_PASSWORD
TEST_DEVICE_ID
TEST_DEVICE_NAME
TEST_API_URL

Currently all tests are run with the npm run test command.

Current Tags

  • 4.1.4                                ...           latest (3 years ago)

56 Versions

  • 4.1.4                                ...           3 years ago
  • 4.1.3                                ...           3 years ago
  • 4.0.3                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           4 years ago
  • 2.4.9                                ...           4 years ago
  • 2.4.8                                ...           4 years ago
  • 2.2.1                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 1.5.5                                ...           4 years ago
  • 1.5.3                                ...           4 years ago
  • 1.5.2                                ...           4 years ago
  • 1.5.1                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.5.3                                ...           4 years ago
  • 0.5.2                                ...           4 years ago
  • 0.5.1                                ...           4 years ago
  • 0.4.8                                ...           4 years ago
  • 0.4.7                                ...           4 years ago
  • 0.5.0                                ...           4 years ago
  • 0.4.6                                ...           4 years ago
  • 0.4.5                                ...           4 years ago
  • 0.4.4                                ...           4 years ago
  • 0.4.3                                ...           4 years ago
  • 0.4.2                                ...           4 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.9                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (19)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |