Skip to content

Commit 91041b3

Browse files
committed
fixes
1 parent a875c07 commit 91041b3

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

src/content/6/en/part6d.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ Most React applications need not only a way to temporarily store the served data
349349

350350
<div class="tasks">
351351

352-
### Exercises 6.19.-6.21.
352+
### Exercises 6.20.-6.22.
353353

354354
Now let's make a new version of the anecdote application that uses the React Query library. Take [this project](https://github.com/fullstack-hy2020/query-anecdotes) as your starting point. The project has a ready-installed JSON Server, the operation of which has been slightly modified. Start the server with <i>npm run server</i>.
355355

356-
#### Exercise 6.19
356+
#### Exercise 6.20
357357

358358
Implement retrieving anecdotes from the server using React Query.
359359

@@ -386,11 +386,11 @@ const result = useQuery(
386386
)
387387
```
388388

389-
#### Exercise 6.20
389+
#### Exercise 6.21
390390

391391
Implement adding new anecdotes to the server using React Query. The application should render a new anecdote by default. Note that the content of the anecdote must be at least 5 characters long, otherwise the server will reject the POST request. You don't have to worry about error handling now.
392392

393-
#### Exercise 6.21
393+
#### Exercise 6.22
394394

395395
Implement voting for anecdotes using again the React Query. The application should automatically render the increased number of votes for the voted anecdote
396396

@@ -759,9 +759,9 @@ As a technical detail, it should be noted that the helper functions <i>useCounte
759759

760760
<div class="tasks">
761761

762-
### Exercises 6.22.-6.23.
762+
### Exercises 6.23.-6.24.
763763

764-
#### Exercise 6.22.
764+
#### Exercise 6.23.
765765

766766
The application has a <i>Notification</i> component for displaying notifications to the user.
767767

@@ -771,7 +771,7 @@ Implement the application's notification state management using the useReducer h
771771

772772
The notification is displayed for five seconds.
773773

774-
#### Exercise 6.23.
774+
#### Exercise 6.24.
775775

776776
As stated in exercise 6.20, the server requires that the content of the anecdote to be added is at least 5 characters long. Now implement error handling for the insertion. In practice, it is sufficient to display a notification to the user in case of a failed POST request:
777777

src/content/6/fi/osa6d.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@ React Query on siis kirjasto, joka ylläpitää frontendissä <i>palvelimen tila
345345

346346
<div class="tasks">
347347

348-
### Tehtävät 6.19.-6.21.
348+
### Tehtävät 6.20.-6.22.
349349

350350
Tehdään nyt anekdoottisovelluksesta uusi, React Query -kirjastoa hyödyntävä versio. Ota lähtökohdaksesi
351351
[täällä](https://github.com/fullstack-hy2020/query-anecdotes) oleva projekti. Projektissa on valmiina asennettuna JSON Server, jonka toimintaa on hieman modifioitu. Käynnistä palvelin komennolla <i>npm run server</i>.
352352

353-
#### Tehtävä 6.19
353+
#### Tehtävä 6.20
354354

355355
Toteuta anekdoottien hakeminen palvelimelta React Queryn avulla.
356356

@@ -382,11 +382,11 @@ const result = useQuery(
382382
)
383383
```
384384

385-
#### Tehtävä 6.20
385+
#### Tehtävä 6.21
386386

387387
Toteuta uusien anekdoottien lisääminen palvelimelle React Queryn avulla. Sovelluksen tulee automaattisesti renderöidä lisätty anekdootti. Huomaa, että anekdootin sisällön pitää olla vähintään 5 merkkiä pitkä, muuten palvelin ei hyväksy POST pyyntöä. Virheiden käsittelystä ei tarvitse nyt välittää.
388388

389-
#### Tehtävä 6.21
389+
#### Tehtävä 6.22
390390

391391
Toteuta anekdoottien äänestäminen hyödyntäen jälleen React Queryä. Sovelluksen tulee automaattisesti renderöidä äänestetyn anekdootin kasvatettu äänimäärä.
392392

@@ -759,9 +759,9 @@ Teknisenä yksityiskohtana todettakoon, että apufunktiot <i>useCounterValue</i>
759759

760760
<div class="tasks">
761761

762-
### Tehtävät 6.22.-6.23.
762+
### Tehtävät 6.23.-6.24.
763763

764-
#### Tehtävä 6.22.
764+
#### Tehtävä 6.23.
765765

766766
Sovelluksessa on valmiina komponentti <i>Notification</i> käyttäjälle tehtävien notifikaatioiden näyttämistä varten.
767767

@@ -771,7 +771,7 @@ Toteuta sovelluksen notifikaation tilan hallinta useReduce-hookin ja contextin a
771771

772772
Notifikaatio näytetään viiden sekunnin ajan.
773773

774-
#### Tehtävä 6.23.
774+
#### Tehtävä 6.24.
775775

776776
Kuten tehtävässä 6.20 todettiin, palvelin vaatii, että lisättävän anekdootin sisällön pituus on vähintään 5 merkkiä. Toteuta nyt lisäämisen yhteyteen virheenkäsittely. Käytännössä riittää, että näytät epäonnistuneen lisäyksen yhteydessä käyttäjälle notifikaation:
777777

src/content/8/en/part8a.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,8 @@ In some cases, it might be beneficial to name the queries. This is the case espe
925925
Through the exercises, we will implement a GraphQL backend for a small library.
926926
Start with [this file](https://github.com/fullstack-hy2020/misc/blob/master/library-backend.js). Remember to _npm init_ and to install dependencies!
927927

928-
Note also that the code does not initially work since the schema definition is not complete.
929-
930928
#### 8.1: The number of books and authors
931929

932-
933930
Implement queries _bookCount_ and _authorCount_ which return the number of books and the number of authors.
934931

935932
The query

src/content/8/en/part8b.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ Through these exercises, we'll implement a frontend for the GraphQL library.
835835
836836
Take [this project](https://github.com/fullstack-hy2020/library-frontend) as a start for your application.
837837
838-
You can implement your application either using the render prop components <i>Query</i> and <i>Mutation</i> of the Apollo Client, or using the hooks provided by Apollo client 3.0.
838+
**Note** if you want, you can also use [React router](/en/part7/react_router) to implement the application's navigation!
839839
840840
#### 8.8: Authors view
841841

src/content/8/en/part8c.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ const mongoose = require('mongoose')
6060
mongoose.set('strictQuery', false)
6161
const Person = require('./models/person')
6262

63+
require('dotenv').config()
64+
6365
const MONGODB_URI = process.env.MONGODB_URI
6466

6567
console.log('connecting to', MONGODB_URI)
@@ -549,11 +551,11 @@ type Mutation {
549551
550552
Complete the program so that all queries (to get _allBooks_ working with the parameter _author_ and _bookCount_ field of an author object is not required) and mutations work.
551553
552-
You might find [this](https://docs.mongodb.com/manual/reference/operator/query/in/) useful.
554+
Regarding the <i>genre</i> parameter of the all books query, the situation is a bit more challenging. The solution is simple, but finding it can be a headache. You might benefit from [this](https://www.mongodb.com/docs/manual/tutorial/query-array-of-documents/).
553555
554556
#### 8.15 Database, part 3
555557
556-
Complete the program so that database validation errors (e.g. book title or author name being too short) are handled sensibly. This means that they cause _UserInputError_ with a suitable error message to be thrown.
558+
Complete the program so that database validation errors (e.g. book title or author name being too short) are handled sensibly. This means that they cause [GraphQLError](https://www.apollographql.com/docs/apollo-server/data/errors/#custom-errors) with a suitable error message to be thrown.
557559
558560
#### 8.16 user and logging in
559561

src/content/8/fi/osa8a.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,6 @@ Joissain tilanteissa voi myös olla hyötyä nimetä kyselyt. Näin on erityises
923923

924924
Tehtävissä toteutetaan yksinkertaisen kirjaston GraphQL:ää tarjoava backend. Ota sovelluksesi lähtökohdaksi [tämä tiedosto](https://github.com/fullstack-hy2020/misc/blob/master/library-backend.js). Muista _npm init_ ja riippuvuuksien asentaminen!
925925

926-
Huomaa, että koodin käynnistäminen aiheuttaa alussa virheen, sillä skeeman määrittely on puutteellinen.
927-
928926
#### 8.1: kirjojen ja kirjailijoiden määrä
929927

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

src/content/8/fi/osa8b.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ Tehtävissä toteutetaan edellisen osan tehtävissä tehdylle backendille fronte
804804
805805
Ota sovelluksesi lähtökohdaksi [tämä projekti](https://github.com/fullstack-hy2020/library-frontend).
806806
807+
**Huom** voit halutessasi käyttää myös [React routeria](/osa7/react_router) sovelluksen navigaation toteuttamiseen!
808+
807809
#### 8.8: Kirjailijoiden näkymä
808810
809811
Toteuta kirjailijoiden näkymä, eli näytä sivulla kaikkien kirjailijoiden tiedot esim. seuraavasti:

src/content/8/fi/osa8c.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ Saamme sovelluksen jo suurilta osin toimimaan seuraavilla muutoksilla:
5656
```js
5757
// ...
5858

59-
6059
const mongoose = require('mongoose')
6160
mongoose.set('strictQuery', false)
6261
const Person = require('./models/person')
6362

63+
require('dotenv').config()
64+
6465
const MONGODB_URI = process.env.MONGODB_URI
6566

6667
console.log('connecting to', MONGODB_URI)
@@ -557,11 +558,11 @@ type Mutation {
557558
558559
Täydennä sovellusta siten, että kaikki kyselyt (kyselyn _allBooks_ parametrin _author_ toimintaansaattaminen on vapaaehtoinen lisätehtävä!) sekä mutaatiot toimivat.
559560
560-
Saatat tässä tehtävässä hyötyä [tästä](https://docs.mongodb.com/manual/reference/operator/query/in/).
561+
Kirjojen haun parametrin <i>genre</i> suhteen tilanne on hieman haastavampi. Ratkaisu on yksinkertainen, mutta sen löytäminen voi tuottaa päänvaivaa. Saatat hyötyä [tästä](https://www.mongodb.com/docs/manual/tutorial/query-array-of-documents/).
561562
562563
#### 8.15 Tietokanta, osa 3
563564
564-
Täydennä sovellusta siten, että tietokannan validointivirheet (esim. liian lyhyt kirjan tai kirjailijan nimi) käsitellään järkevästi, eli niiden seurauksena heitetään poikkeus _UserInputError_, jolle asetetaan sopiva virheviesti.
565+
Täydennä sovellusta siten, että tietokannan validointivirheet (esim. liian lyhyt kirjan tai kirjailijan nimi) käsitellään järkevästi, eli niiden seurauksena heitetään poikkeus [GraphQLError](https://www.apollographql.com/docs/apollo-server/data/errors/#custom-errors), jolle asetetaan sopiva virheviesti.
565566
566567
#### 8.16 käyttäjä ja kirjautuminen
567568

0 commit comments

Comments
 (0)