├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── README.md
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── src
├── app
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── graphql.module.ts
│ ├── list.component.ts
│ ├── mergeLink.ts
│ ├── schema
│ │ ├── client-schema.ts
│ │ ├── fixtures.ts
│ │ ├── index.ts
│ │ ├── messages.ts
│ │ └── remoteSchemaExtension.ts
│ ├── selector.component.ts
│ └── types.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── typings.d.ts
├── tsconfig.json
└── tslint.json
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "apollo-angular-state-v4fojn"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Examples managing local state with Apollo
2 |
3 | 1. [Local state only with apollo-link-state](https://github.com/Urigo/apollo-local-state-examples/tree/apollo-link-state-all-local) - [live example](https://stackblitz.com/edit/apollo-angular-state-v4fojn)
4 | 2. [Local and remote state with apollo-link-state](https://github.com/Urigo/apollo-local-state-examples/tree/apollo-link-state-with-remote) - [live example](https://stackblitz.com/edit/apollo-angular-state-zudqeq)
5 | 3. [Local and remote schemas merged using schema stitching](https://github.com/Urigo/apollo-local-state-examples/tree/local-remote-schemas-merged) - [live example](https://stackblitz.com/edit/apollo-angular-state-cnoetk)
6 |
7 |
8 | Thanks to [James Baxley](https://github.com/jbaxleyiii) and [Kamil Kisiela](https://github.com/kamilkisiela/) for inspiring and building everything to make that possible
9 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AngularTemplatePage } from './app.po';
2 |
3 | describe('angular-template App', () => {
4 | let page: AngularTemplatePage;
5 |
6 | beforeEach(() => {
7 | page = new AngularTemplatePage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AngularTemplatePage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-template",
3 | "description": "",
4 | "homepage": "https://stackblitz.com/edit/apollo-angular-state-v4fojn",
5 | "dependencies": {
6 | "@angular/animations": "^4.0.0",
7 | "@angular/common": "4.3.6",
8 | "@angular/compiler": "4.3.6",
9 | "@angular/core": "4.3.6",
10 | "@angular/forms": "4.3.6",
11 | "@angular/http": "4.3.6",
12 | "@angular/platform-browser": "4.3.6",
13 | "@angular/platform-browser-dynamic": "4.3.6",
14 | "@angular/router": "4.3.6",
15 | "core-js": "2.4.1",
16 | "rxjs": "5.4.2",
17 | "zone.js": "0.8.12",
18 | "graphql": "0.11.7",
19 | "apollo-link": "1.0.0",
20 | "graphql-tag": "2.5.0",
21 | "apollo-client": "2.0.1",
22 | "apollo-angular": "1.0.0-beta.2",
23 | "apollo-link-state": "0.0.2",
24 | "apollo-cache-inmemory": "1.0.0",
25 | "apollo-angular-link-http": "1.0.0-beta.3"
26 | },
27 | "version": "0.0.0",
28 | "license": "MIT",
29 | "scripts": {
30 | "ng": "ng",
31 | "start": "ng serve",
32 | "build": "ng build",
33 | "test": "ng test",
34 | "lint": "ng lint",
35 | "e2e": "ng e2e"
36 | },
37 | "private": true,
38 | "devDependencies": {
39 | "@angular/cli": "1.2.1",
40 | "@angular/compiler-cli": "^4.0.0",
41 | "@angular/language-service": "^4.0.0",
42 | "@types/jasmine": "~2.5.53",
43 | "@types/jasminewd2": "~2.0.2",
44 | "@types/node": "~6.0.60",
45 | "codelyzer": "~3.0.1",
46 | "jasmine-core": "~2.6.2",
47 | "jasmine-spec-reporter": "~4.1.0",
48 | "karma": "~1.7.0",
49 | "karma-chrome-launcher": "~2.1.1",
50 | "karma-cli": "~1.0.1",
51 | "karma-coverage-istanbul-reporter": "^1.2.1",
52 | "karma-jasmine": "~1.1.0",
53 | "karma-jasmine-html-reporter": "^0.2.2",
54 | "protractor": "~5.1.2",
55 | "ts-node": "~3.0.4",
56 | "tslint": "~5.3.2",
57 | "typescript": "~2.3.3"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app',
5 | template: `
6 |