angular1-apollo
Angular 1.0 client for Apollo
Last updated 3 years ago by urigo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install angular1-apollo 
SYNC missed versions from official npm registry.

angular1-apollo

npm version Get on Slack bitHound Overall Score

Use your GraphQL server data in your Angular 1.0 app, with the Apollo Client.

Install

npm install angular1-apollo apollo-client --save

API

angular.module('app', [
  'angular-apollo'
])

Default client

ApolloProvider.defaultClient

import AngularApollo from 'angular1-apollo'
import ApolloClient from 'apollo-client';

angular.module('app', [
  AngularApollo
]).config((apolloProvider) => {
  const client = new ApolloClient();

  apolloProvider.defaultClient(client);
});

Queries

Apollo.query(options): Promise<ApolloQueryResult>

See documentation

import gql from 'graphql-tag';

angular.module('app')
  .controller('AppCtrl', (apollo) => {
    apollo.query({
      query: gql`
        query getHeroes {
          heroes {
            name
            power
          }
        }
      `
    }).then(result => {
      console.log('got data', result);
    });
  });

Mutations

Apollo.mutate(options): Promise<ApolloQueryResult>

See documentation

import gql from 'graphql-tag';

angular.module('app')
  .controller('AppCtrl', (apollo) => {
    apollo.mutate({
      mutation: gql`
        mutation newHero($name: String!) {
          addHero(name: $name) {
            power
          }
        }
      `,
      variables: {
        name: 'Batman'
      }
    }).then(result => {
      console.log('got data', result);
    });
  });

Development

This project uses TypeScript for static typing and TSLint for linting. You can get both of these built into your editor with no configuration by opening this project in Visual Studio Code, an open source IDE which is available for free on all platforms.

Current Tags

  • 0.3.0                                ...           latest (3 years ago)

7 Versions

  • 0.3.0                                ...           3 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.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 2
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |