Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

angular-apollo

1.1.0 • Public • Published

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;
            }) ;
    };
}
 
class MyConfig extends Config {
    baseUrl: 'http://www.example.com';
}
 
bootstrap(AppComponent, [
    HTTP_PROVIDERS,
    ListService,
    ApiService,
    {
        provide: Config,
        useClass: MyConfig
    }
    ]]);

For an ionic2 project:

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, [{
      provide: ApiService,
      useFactory: (http: Http) => {
          new ApiService(http, {baseUrl:'https://www.example.com'})
        }, 
      deps: [Http]
    },
    ListService,
    ApiService]);

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.

Keywords

none

Install

npm i [email protected]

Version

1.1.0

License

ISC

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar