You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/8/en/part8a.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -250,9 +250,11 @@ Let's implement a GraphQL server with today's leading library: [Apollo Server](h
250
250
Create a new npm project with _npm init_ and install the required dependencies.
251
251
252
252
```bash
253
-
npm install @apollo/server graphql
253
+
npm install apollo-server@3.10.1 graphql
254
254
```
255
255
256
+
**Note** at the time of writing (10th Dec 2022) the code used in this part is not fully compatible with the new version of the Apollo Server, and because of this, if you want everything to work smoothly you should install the version _3.10.1_. Material shall be updated to use the most recent Apollo Server in early 2023.
257
+
256
258
Also create a `index.js` file in your project's root directory.
257
259
258
260
The initial code is as follows:
@@ -490,7 +492,6 @@ Person: {
490
492
491
493
### Object within an object
492
494
493
-
494
495
Let's modify the schema a bit
495
496
496
497
```js
@@ -533,7 +534,6 @@ query {
533
534
}
534
535
```
535
536
536
-
537
537
and the response is now a person object, which <i>contains</i> an address object.
538
538
539
539
```js
@@ -550,7 +550,6 @@ and the response is now a person object, which <i>contains</i> an address object
550
550
}
551
551
```
552
552
553
-
554
553
We still save the persons in the server the same way we did before.
555
554
556
555
```js
@@ -569,10 +568,8 @@ let persons = [
569
568
570
569
The person-objects saved in the server are not exactly the same as the GraphQL type <i>Person</i> objects described in the schema.
571
570
572
-
573
571
Contrary to the <i>Person</i> type, the <i>Address</i> type does not have an <i>id</i> field, because they are not saved into their own separate data structure in the server.
574
572
575
-
576
573
Because the objects saved in the array do not have an <i>address</i> field, the default resolver is not sufficient.
577
574
Let's add a resolver for the <i>address</i> field of <i>Person</i> type :
578
575
@@ -936,7 +933,13 @@ In some cases, it might be beneficial to name the queries. This is the case espe
936
933
Through the exercises, we will implement a GraphQL backend for a small library.
937
934
Start with [this file](https://github.com/fullstack-hy2020/misc/blob/master/library-backend.js). Remember to _npm init_ and to install dependencies!
938
935
939
-
Note that the code does not initially work since the schema definition is not complete.
936
+
**Note** at the time of writing (10th Dec 2022) the code used in this part is not fully compatible with the new version of the Apollo Server, and because of this, if you want everything to work smoothly you should install the version _3.10.1_:
Copy file name to clipboardExpand all lines: src/content/8/fi/osa8a.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,9 +245,11 @@ Toteutetaan nyt GraphQL-palvelin tämän hetken johtavaa kirjastoa [Apollo Serve
245
245
Luodaan uusi npm-projekti komennolla _npm init_ ja asennetaan tarvittavat riippuvuudet
246
246
247
247
```bash
248
-
npm install apollo-server graphql
248
+
npm install apollo-server@3.10.1 graphql
249
249
```
250
250
251
+
**Huom:** tätä kirjoittaessa (10.12.2022) tämän osan koodi ei ole täysin yhteensopivaa uusimman Apollo Serverin version kanssa. Tämän takia kannattaa asentaa versio _3.10.1_ jos haluat että koodi toimii sellaisenaan. Osa päivitetään vuoden 2023 alkupuolella.
252
+
251
253
Alustava toteutus on seuraavassa
252
254
253
255
```js
@@ -919,6 +921,13 @@ Tehtävissä toteutetaan yksinkertaisen kirjaston GraphQL:ää tarjoava backend.
919
921
920
922
Huomaa, että koodin käynnistäminen aiheuttaa alussa virheen, sillä skeeman määrittely on puutteellinen.
921
923
924
+
**Huom:** tätä kirjoittaessa (10.12.2022) tämän osan koodi ei ole täysin yhteensopivaa uusimman Apollo Serverin version kanssa. Tämän takia kannattaa asentaa versio _3.10.1_ jos haluat että koodi toimii sellaisenaan. Osa päivitetään vuoden 2023 alkupuolella.
0 commit comments