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/6/en/part6d.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -349,11 +349,11 @@ Most React applications need not only a way to temporarily store the served data
349
349
350
350
<divclass="tasks">
351
351
352
-
### Exercises 6.19.-6.21.
352
+
### Exercises 6.20.-6.22.
353
353
354
354
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>.
355
355
356
-
#### Exercise 6.19
356
+
#### Exercise 6.20
357
357
358
358
Implement retrieving anecdotes from the server using React Query.
359
359
@@ -386,11 +386,11 @@ const result = useQuery(
386
386
)
387
387
```
388
388
389
-
#### Exercise 6.20
389
+
#### Exercise 6.21
390
390
391
391
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.
392
392
393
-
#### Exercise 6.21
393
+
#### Exercise 6.22
394
394
395
395
Implement voting for anecdotes using again the React Query. The application should automatically render the increased number of votes for the voted anecdote
396
396
@@ -759,9 +759,9 @@ As a technical detail, it should be noted that the helper functions <i>useCounte
759
759
760
760
<divclass="tasks">
761
761
762
-
### Exercises 6.22.-6.23.
762
+
### Exercises 6.23.-6.24.
763
763
764
-
#### Exercise 6.22.
764
+
#### Exercise 6.23.
765
765
766
766
The application has a <i>Notification</i> component for displaying notifications to the user.
767
767
@@ -771,7 +771,7 @@ Implement the application's notification state management using the useReducer h
771
771
772
772
The notification is displayed for five seconds.
773
773
774
-
#### Exercise 6.23.
774
+
#### Exercise 6.24.
775
775
776
776
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:
Copy file name to clipboardExpand all lines: src/content/6/fi/osa6d.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -345,12 +345,12 @@ React Query on siis kirjasto, joka ylläpitää frontendissä <i>palvelimen tila
345
345
346
346
<divclass="tasks">
347
347
348
-
### Tehtävät 6.19.-6.21.
348
+
### Tehtävät 6.20.-6.22.
349
349
350
350
Tehdään nyt anekdoottisovelluksesta uusi, React Query -kirjastoa hyödyntävä versio. Ota lähtökohdaksesi
351
351
[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>.
352
352
353
-
#### Tehtävä 6.19
353
+
#### Tehtävä 6.20
354
354
355
355
Toteuta anekdoottien hakeminen palvelimelta React Queryn avulla.
356
356
@@ -382,11 +382,11 @@ const result = useQuery(
382
382
)
383
383
```
384
384
385
-
#### Tehtävä 6.20
385
+
#### Tehtävä 6.21
386
386
387
387
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ää.
388
388
389
-
#### Tehtävä 6.21
389
+
#### Tehtävä 6.22
390
390
391
391
Toteuta anekdoottien äänestäminen hyödyntäen jälleen React Queryä. Sovelluksen tulee automaattisesti renderöidä äänestetyn anekdootin kasvatettu äänimäärä.
392
392
@@ -759,9 +759,9 @@ Teknisenä yksityiskohtana todettakoon, että apufunktiot <i>useCounterValue</i>
759
759
760
760
<divclass="tasks">
761
761
762
-
### Tehtävät 6.22.-6.23.
762
+
### Tehtävät 6.23.-6.24.
763
763
764
-
#### Tehtävä 6.22.
764
+
#### Tehtävä 6.23.
765
765
766
766
Sovelluksessa on valmiina komponentti <i>Notification</i> käyttäjälle tehtävien notifikaatioiden näyttämistä varten.
767
767
@@ -771,7 +771,7 @@ Toteuta sovelluksen notifikaation tilan hallinta useReduce-hookin ja contextin a
771
771
772
772
Notifikaatio näytetään viiden sekunnin ajan.
773
773
774
-
#### Tehtävä 6.23.
774
+
#### Tehtävä 6.24.
775
775
776
776
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:
Copy file name to clipboardExpand all lines: src/content/8/en/part8b.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -835,7 +835,7 @@ Through these exercises, we'll implement a frontend for the GraphQL library.
835
835
836
836
Take [this project](https://github.com/fullstack-hy2020/library-frontend) as a start for your application.
837
837
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!
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.
551
553
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/).
553
555
554
556
#### 8.15 Database, part 3
555
557
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.
For this to work, we have to install some dependencies:
710
+
For this to work, we have to install a dependency:
711
711
712
712
```bash
713
-
npm install @apollo/client graphql-ws
713
+
npm install graphql-ws
714
714
```
715
715
716
716
The new configuration is due to the fact that the application must have an HTTP connection as well as a WebSocket connection to the GraphQL server.
@@ -1100,7 +1100,7 @@ Start using subscriptions in the client, and subscribe to _bookAdded_. When new
1100
1100
1101
1101
#### 8.25: Subscriptions - client, part 2
1102
1102
1103
-
Keep the application's view updated when the server notifies about new books. You can test your implementation by opening the app in two browser tabs and adding a new book in one tab. Adding the new book should update the view in both tabs.
1103
+
Keep the application's book view updated when the server notifies about new books (you can ignore the author view!). You can test your implementation by opening the app in two browser tabs and adding a new book in one tab. Adding the new book should update the view in both tabs.
Copy file name to clipboardExpand all lines: src/content/8/fi/osa8a.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -923,8 +923,6 @@ Joissain tilanteissa voi myös olla hyötyä nimetä kyselyt. Näin on erityises
923
923
924
924
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!
925
925
926
-
Huomaa, että koodin käynnistäminen aiheuttaa alussa virheen, sillä skeeman määrittely on puutteellinen.
927
-
928
926
#### 8.1: kirjojen ja kirjailijoiden määrä
929
927
930
928
Toteuta kyselyt _bookCount_ ja _authorCount_ jotka palauttavat kirjojen ja kirjailijoiden lukumäärän.
0 commit comments