Skip to content

Commit 79b3f7a

Browse files
committed
apollo fix
1 parent 93579ec commit 79b3f7a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/content/8/en/part8a.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ Let's implement a GraphQL server with today's leading library: [Apollo Server](h
250250
Create a new npm project with _npm init_ and install the required dependencies.
251251

252252
```bash
253-
npm install @apollo/server graphql
253+
npm install apollo-server@3.10.1 graphql
254254
```
255255

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+
256258
Also create a `index.js` file in your project's root directory.
257259

258260
The initial code is as follows:
@@ -490,7 +492,6 @@ Person: {
490492

491493
### Object within an object
492494

493-
494495
Let's modify the schema a bit
495496

496497
```js
@@ -533,7 +534,6 @@ query {
533534
}
534535
```
535536

536-
537537
and the response is now a person object, which <i>contains</i> an address object.
538538

539539
```js
@@ -550,7 +550,6 @@ and the response is now a person object, which <i>contains</i> an address object
550550
}
551551
```
552552

553-
554553
We still save the persons in the server the same way we did before.
555554

556555
```js
@@ -569,10 +568,8 @@ let persons = [
569568

570569
The person-objects saved in the server are not exactly the same as the GraphQL type <i>Person</i> objects described in the schema.
571570

572-
573571
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.
574572

575-
576573
Because the objects saved in the array do not have an <i>address</i> field, the default resolver is not sufficient.
577574
Let's add a resolver for the <i>address</i> field of <i>Person</i> type :
578575

@@ -936,7 +933,13 @@ In some cases, it might be beneficial to name the queries. This is the case espe
936933
Through the exercises, we will implement a GraphQL backend for a small library.
937934
Start with [this file](https://github.com/fullstack-hy2020/misc/blob/master/library-backend.js). Remember to _npm init_ and to install dependencies!
938935

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_:
937+
938+
```bash
939+
npm install [email protected] graphql
940+
```
941+
942+
Note also that the code does not initially work since the schema definition is not complete.
940943

941944
#### 8.1: The number of books and authors
942945

src/content/8/fi/osa8a.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ Toteutetaan nyt GraphQL-palvelin tämän hetken johtavaa kirjastoa [Apollo Serve
245245
Luodaan uusi npm-projekti komennolla _npm init_ ja asennetaan tarvittavat riippuvuudet
246246

247247
```bash
248-
npm install apollo-server graphql
248+
npm install apollo-server@3.10.1 graphql
249249
```
250250

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+
251253
Alustava toteutus on seuraavassa
252254

253255
```js
@@ -919,6 +921,13 @@ Tehtävissä toteutetaan yksinkertaisen kirjaston GraphQL:ää tarjoava backend.
919921

920922
Huomaa, että koodin käynnistäminen aiheuttaa alussa virheen, sillä skeeman määrittely on puutteellinen.
921923

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.
925+
926+
Asenna siis riippuvuudet seuraavasti:
927+
928+
```bash
929+
npm install [email protected] graphql
930+
```
922931
#### 8.1: kirjojen ja kirjailijoiden määrä
923932

924933
Toteuta kyselyt _bookCount_ ja _authorCount_ jotka palauttavat kirjojen ja kirjailijoiden lukumäärän.

0 commit comments

Comments
 (0)