Skip to content

Commit f897e69

Browse files
committed
update to Angular 10
1 parent c87c7f9 commit f897e69

11 files changed

+4877
-5747
lines changed

browserslist .browserslistrc

File renamed without changes.

.prettierrc

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
2-
"semi": true,
32
"singleQuote": true,
4-
"bracketSpacing": true,
5-
"tabWidth": 2,
6-
"useTabs": false,
73
"trailingComma": "none"
84
}

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# Angular 9 GraphQL Apollo Example
1+
# Angular 10 GraphQL Apollo Example
22

3-
This is a simple Angular 9 example that uses Apollo Angular to run queries and mutations on a mock GraphQL Backend.
3+
This is a simple Angular 10 example that uses Apollo Angular to run queries and mutations on a mock GraphQL Backend.
44

5-
Run `npm run start` to start the json-graphql-serve and the Angular client.
5+
Run `npm run start` to start the json-graphql-server and the Angular client.
66

77
## Tools
88

99
- [json-graphql-server](https://github.com/marmelab/json-graphql-server)
1010
- [Apollo Angular](https://www.npmjs.com/package/apollo-angular)
1111
- [Tailwind](https://tailwindcss.com)
1212
- [ng-tailwindcss](https://github.com/tehpsalmist/ng-tailwindcss)
13+
14+
## Versions
15+
16+
- [Version 1.1](https://github.com/DavidBuck/angular-graphql-apollo-example/releases/tag/v1.1) - Angular version 10.1.6.
17+
18+
- [Version 1.0](https://github.com/DavidBuck/angular-graphql-apollo-example/releases/tag/v1.0) - Angular version 9.1.1.

e2e/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../out-tsc/e2e",
55
"module": "commonjs",
6-
"target": "es5",
6+
"target": "es2018",
77
"types": [
88
"jasmine",
99
"jasminewd2",

package-lock.json

+4,720-5,669
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+36-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-graphql-apollo-example",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Angular GraphQL Apollo example",
55
"author": "David Buck",
66
"repository": "github:davidbuck/angular-graphql-apollo-example",
@@ -17,50 +17,46 @@
1717
},
1818
"private": true,
1919
"dependencies": {
20-
"@angular/animations": "~9.1.1",
21-
"@angular/common": "~9.1.1",
22-
"@angular/compiler": "~9.1.1",
23-
"@angular/core": "~9.1.1",
24-
"@angular/forms": "~9.1.1",
25-
"@angular/platform-browser": "~9.1.1",
26-
"@angular/platform-browser-dynamic": "~9.1.1",
27-
"@angular/router": "~9.1.1",
28-
"apollo-angular": "^1.8.0",
29-
"apollo-angular-link-http": "^1.9.0",
30-
"apollo-cache-inmemory": "^1.6.5",
31-
"apollo-client": "^2.6.8",
32-
"apollo-link": "^1.2.11",
33-
"graphql": "^14.6.0",
34-
"graphql-tag": "^2.10.3",
35-
"rxjs": "~6.5.5",
36-
"tslib": "^1.10.0",
37-
"zone.js": "~0.10.2"
20+
"@angular/animations": "^10.1.6",
21+
"@angular/common": "^10.1.6",
22+
"@angular/compiler": "^10.1.6",
23+
"@angular/core": "^10.1.6",
24+
"@angular/forms": "^10.1.6",
25+
"@angular/platform-browser": "^10.1.6",
26+
"@angular/platform-browser-dynamic": "^10.1.6",
27+
"@angular/router": "^10.1.6",
28+
"apollo-angular": "^2.0.4",
29+
"graphql": "^15.0.0",
30+
"rxjs": "~6.6.3",
31+
"tslib": "^2.0.0",
32+
"zone.js": "~0.10.2",
33+
"@apollo/client": "^3.0.0"
3834
},
3935
"devDependencies": {
40-
"@angular-devkit/build-angular": "~0.901.1",
41-
"@angular/cli": "^9.1.1",
42-
"@angular/compiler-cli": "~9.1.1",
43-
"@angular/language-service": "~9.1.1",
44-
"@types/jasmine": "~3.3.8",
36+
"@angular-devkit/build-angular": "^0.1001.7",
37+
"@angular/cli": "^10.1.7",
38+
"@angular/compiler-cli": "^10.1.6",
39+
"@angular/language-service": "^10.1.6",
40+
"@types/jasmine": "^3.5.14",
4541
"@types/jasminewd2": "~2.0.3",
46-
"@types/node": "^12.11.1",
47-
"codelyzer": "^5.1.2",
48-
"concurrently": "^5.1.0",
49-
"jasmine-core": "~3.4.0",
50-
"jasmine-spec-reporter": "~4.2.1",
42+
"@types/node": "^12.12.68",
43+
"codelyzer": "^6.0.1",
44+
"concurrently": "^5.3.0",
45+
"jasmine-core": "^3.6.0",
46+
"jasmine-spec-reporter": "~5.0.0",
5147
"json-graphql-server": "^2.1.3",
52-
"karma": "~4.1.0",
53-
"karma-chrome-launcher": "~2.2.0",
54-
"karma-coverage-istanbul-reporter": "~2.0.1",
55-
"karma-jasmine": "~2.0.1",
56-
"karma-jasmine-html-reporter": "^1.5.3",
57-
"prettier": "^1.19.1",
58-
"protractor": "^5.4.3",
59-
"tailwindcss": "^1.2.0",
60-
"ts-node": "~7.0.0",
61-
"tslint": "~5.15.0",
48+
"karma": "~5.0.0",
49+
"karma-chrome-launcher": "~3.1.0",
50+
"karma-coverage-istanbul-reporter": "~3.0.2",
51+
"karma-jasmine": "~4.0.0",
52+
"karma-jasmine-html-reporter": "^1.5.0",
53+
"prettier": "^2.1.2",
54+
"protractor": "~7.0.0",
55+
"tailwindcss": "^1.9.4",
56+
"ts-node": "^8.3.0",
57+
"tslint": "~6.1.0",
6258
"tslint-config-prettier": "^1.18.0",
6359
"tslint-plugin-prettier": "^2.3.0",
64-
"typescript": "~3.8.3"
60+
"typescript": "~4.0.3"
6561
}
6662
}

src/app/app.component.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ export class AppComponent implements OnInit {
2323

2424
addPostGraphql() {
2525
this.dataService.addPostGraphql(this.newPost).subscribe(
26-
res => console.log(res),
27-
err => console.error(err)
26+
(res) => console.log(res),
27+
(err) => console.error(err)
2828
);
2929
}
3030

3131
updatePostGraphql() {
3232
this.dataService
3333
.updatePostGraphql({ id: 4, title: 'Updated Post' })
3434
.subscribe(
35-
res => console.log(res),
36-
err => console.error(err)
35+
(res) => console.log(res),
36+
(err) => console.error(err)
3737
);
3838
}
3939

4040
deletePostGraphql() {
4141
this.dataService.deletePostGraphql(1).subscribe(
42-
res => console.log(res),
43-
err => console.error(err)
42+
(res) => console.log(res),
43+
(err) => console.error(err)
4444
);
4545
}
4646
}

src/app/graphql-server.service.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { gql, Apollo } from 'apollo-angular';
12
import { Injectable } from '@angular/core';
23
import { Observable } from 'rxjs';
3-
import gql from 'graphql-tag';
4-
import { Apollo } from 'apollo-angular';
4+
55
import { Post } from './post';
66

77
@Injectable({
@@ -49,9 +49,12 @@ export class GraphqlServerService {
4949
mutation: this.query,
5050
variables: post,
5151
update: (store, { data: { createPost } }) => {
52-
const data: any = store.readQuery({ query: this.allPosts });
53-
data.allPosts = [...data.allPosts, createPost];
54-
store.writeQuery({ query: this.allPosts, data });
52+
const existingPosts: any = store.readQuery({ query: this.allPosts });
53+
const newPosts = [...existingPosts.allPosts, createPost];
54+
store.writeQuery({
55+
query: this.allPosts,
56+
data: { allPosts: newPosts }
57+
});
5558
}
5659
});
5760
}
@@ -84,10 +87,14 @@ export class GraphqlServerService {
8487
return this.apollo.mutate({
8588
mutation: this.query,
8689
variables: { id: deleteId },
87-
update: store => {
88-
const data: any = store.readQuery({ query: this.allPosts });
89-
data.allPosts.splice(deleteId - 1, 1);
90-
store.writeQuery({ query: this.allPosts, data });
90+
update: (store) => {
91+
const existingPosts: any = store.readQuery({ query: this.allPosts });
92+
const updatedPosts = [...existingPosts.allPosts];
93+
updatedPosts.splice(deleteId - 1, 1);
94+
store.writeQuery({
95+
query: this.allPosts,
96+
data: { allPosts: updatedPosts }
97+
});
9198
}
9299
});
93100
}

src/app/graphql.module.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { APOLLO_OPTIONS } from 'apollo-angular';
2+
import { HttpLink } from 'apollo-angular/http';
3+
import { InMemoryCache } from '@apollo/client/core';
14
import { NgModule } from '@angular/core';
2-
import { ApolloModule, APOLLO_OPTIONS } from 'apollo-angular';
3-
import { HttpLinkModule, HttpLink } from 'apollo-angular-link-http';
4-
import { InMemoryCache } from 'apollo-cache-inmemory';
55

66
const uri = 'http://localhost:3000/graphql';
77

@@ -13,7 +13,6 @@ export function createApollo(httpLink: HttpLink) {
1313
}
1414

1515
@NgModule({
16-
exports: [ApolloModule, HttpLinkModule],
1716
providers: [
1817
{
1918
provide: APOLLO_OPTIONS,

tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"declaration": false,
88
"downlevelIteration": true,
99
"experimentalDecorators": true,
10-
"module": "esnext",
10+
"module": "es2020",
1111
"moduleResolution": "node",
1212
"importHelpers": true,
1313
"target": "es2015",
@@ -18,7 +18,8 @@
1818
"es2018",
1919
"dom",
2020
"esnext.asynciterable"
21-
]
21+
],
22+
"allowSyntheticDefaultImports": true
2223
},
2324
"angularCompilerOptions": {
2425
"fullTemplateTypeCheck": true,

tslint.json

+83-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
{
2-
"extends": [
3-
"tslint:recommended",
4-
"tslint-plugin-prettier",
5-
"tslint-config-prettier"
6-
],
2+
"extends": "tslint:recommended",
73
"rules": {
4+
"align": {
5+
"options": [
6+
"parameters",
7+
"statements"
8+
]
9+
},
810
"prettier": true,
911
"array-type": false,
12+
"arrow-return-shorthand": true,
1013
"arrow-parens": false,
1114
"deprecation": {
1215
"severity": "warning"
1316
},
1417
"component-class-suffix": true,
18+
"curly": true,
1519
"contextual-lifecycle": true,
1620
"directive-class-suffix": true,
17-
"directive-selector": [true, "attribute", "app", "camelCase"],
18-
"component-selector": [true, "element", "app", "kebab-case"],
21+
"directive-selector": [
22+
true,
23+
"attribute",
24+
"app",
25+
"camelCase"
26+
],
27+
"eofline": true,
28+
"component-selector": [
29+
true,
30+
"element",
31+
"app",
32+
"kebab-case"
33+
],
34+
"import-spacing": true,
35+
"indent": {
36+
"options": [
37+
"spaces"
38+
]
39+
},
1940
"import-blacklist": [true, "rxjs/Rx"],
2041
"interface-name": false,
2142
"max-classes-per-file": false,
@@ -52,11 +73,64 @@
5273
"no-output-native": true,
5374
"no-output-on-prefix": true,
5475
"no-output-rename": true,
76+
"semicolon": {
77+
"options": [
78+
"always"
79+
]
80+
},
81+
"space-before-function-paren": {
82+
"options": {
83+
"anonymous": "never",
84+
"asyncArrow": "always",
85+
"constructor": "never",
86+
"method": "never",
87+
"named": "never"
88+
}
89+
},
5590
"no-outputs-metadata-property": true,
5691
"template-banana-in-box": true,
5792
"template-no-negated-async": true,
93+
"typedef-whitespace": {
94+
"options": [
95+
{
96+
"call-signature": "nospace",
97+
"index-signature": "nospace",
98+
"parameter": "nospace",
99+
"property-declaration": "nospace",
100+
"variable-declaration": "nospace"
101+
},
102+
{
103+
"call-signature": "onespace",
104+
"index-signature": "onespace",
105+
"parameter": "onespace",
106+
"property-declaration": "onespace",
107+
"variable-declaration": "onespace"
108+
}
109+
]
110+
},
58111
"use-lifecycle-interface": true,
59-
"use-pipe-transform-interface": true
112+
"use-pipe-transform-interface": true,
113+
"variable-name": {
114+
"options": [
115+
"ban-keywords",
116+
"check-format",
117+
"allow-pascal-case"
118+
]
119+
},
120+
"whitespace": {
121+
"options": [
122+
"check-branch",
123+
"check-decl",
124+
"check-operator",
125+
"check-separator",
126+
"check-type",
127+
"check-typecast"
128+
]
129+
}
60130
},
61-
"rulesDirectory": ["codelyzer"]
131+
"rulesDirectory": [
132+
"codelyzer",
133+
"tslint-plugin-prettier",
134+
"tslint-config-prettier"
135+
]
62136
}

0 commit comments

Comments
 (0)