Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-apollo

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-apollo

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

  • 2.4.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-12.5%
Maintainers
4
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 13 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc