Skip to content

Commit

Permalink
Merge pull request #95 from bmeviauac01/hf2024graphql
Browse files Browse the repository at this point in the history
Hf2024graphql
  • Loading branch information
tibitoth authored Dec 1, 2024
2 parents c15d84d + bf8b9f7 commit 8ddf843
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
36 changes: 36 additions & 0 deletions docs/en/homework/graphql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ In the following tasks, you will need to come up with the query and the correspo
Do this, and test it with a query that filters by category names.
The code completion will be very helpful in creating the query.
When submitting the solution, the query should be submitted in the `q3_1.txt` file, where you need to filter by the `"Building Items"` category.
The results should be in the same format as in Exercise 1.8.

!!! note ""
Filtering has a unique syntax.
Expand All @@ -264,6 +265,7 @@ In the following tasks, you will need to come up with the query and the correspo

1. Your second task is to add sorting and pagination to the `GetOrders` function. Annotate the `GetOrders` function with the appropriate attributes, then set up the sorting and pagination options when registering GraphQL. To test it, you will need to modify the query, and constructing the query is also part of the task.
When submitting the solution, you must also submit the query in the `q3_2.txt` file, where the query contains 2 `Order` items (due to pagination) and sorts them in descending order by `id`.
The response to the query should arrive in the format below!

!!! note ""
Pagination is a very important feature when querying large databases, as sending and processing entire tables is not ideal. Instead, a common solution is that the client requests data in batches, for example, 10 items at a time, and only requests the next batch when navigating to the next page.
Expand All @@ -272,6 +274,40 @@ When submitting the solution, you must also submit the query in the `q3_2.txt` f

The documentation for sorting can be found here: https://chillicream.com/docs/hotchocolate/v14/fetching-data/sorting

```json
{
"data": {
"orders": {
"edges": [
{
"node": {
"id": 5,
"orderItems": [
{
"amount": 2,
"product": {
"name": "Lego City harbour",
"price": 172268.75,
"stock": 12
}
},
{
"amount": 1,
"product": {
"name": "Activity playgim",
"price": 7488,
"stock": 21
}
}
]
}
}
]
}
}
}
```

!!! example "SUBMISSION"
Upload the modified C# source code.
Save the queries from parts 1 and 2 of task 3 as `q3_1.txt` and `q3_2.txt`, place them in the root folder along with the images, and submit them.
Expand Down
39 changes: 38 additions & 1 deletion docs/hu/homework/graphql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ A következő feladatokban neked kell kitalálnod a lekérdezést is és a funkc
1. Az első feladatban található `productsByCategory` hívás kiváltható, ha a `GetProducts` függvényünkre engedélyezzük a beépített szűrést.
Tedd meg, majd teszteld egy olyan lekérdezéssel, ami kategóriák nevére szűr.
A lekérdezés elkészítésében nagy segítségedre lesz a kódkiegészítés.
A megoldás leadásakor a lekérdezést is le kell adnod `q3_1.txt` fájlban, ahol a `"Building Items"` kategóriára kell szűrnöd.
A megoldás leadásakor a lekérdezést is le kell adnod `q3_1.txt` fájlban, ahol a `"Building Items"` kategóriára kell szűrnöd. A visszatérési adatok előállításakor az 1. Feladat 8-as pontja szerinti módon kell előállítani a választ.
!!! note ""
A szűrésnek egyedi szintaxisa van.
Expand All @@ -267,6 +267,7 @@ A megoldás leadásakor a lekérdezést is le kell adnod `q3_1.txt` fájlban, ah
1. A második feladatod a rendezés és a lapozhatóság hozzáadása a `GetOrders` függvényhez. A `GetOrders` függvényt annotáld a megfelelő attribútumokkal, majd a GraphQL regisztrálásakor állítsd be a sorbarendezés és rendezés lehetőségeit. A kipróbáláshoz a lekérdezést módosítani kell, a lekérdezés összeállítása is a feladat része.
A megoldás leadásakor a lekérdezést is le kell adnod `q3_2.txt` fájlban, ahol a lekérdezés 2 darab `Order`-t tartalmaz (lapozás következtében) és `id` alapján csökkenő sorrendben tenned őket.
Figyelj rá, hogy a válasz a lentebb megadott formátumban érkezzen!
!!! note ""
A lapozhatóság rendkívül fontos tulajdonság lesz, amikor nagyméretű adatbázisokból kérünk le adatokat, hiszen teljes táblák elküldése és feldolgozása sem szerencsés. Ehelyett gyakori megoldás, hogy például 10-esével kéri le a kliens az adatokat és a következő oldalra navigálva kéri csak le a következő 10-et.
Expand All @@ -275,6 +276,42 @@ A megoldás leadásakor a lekérdezést is le kell adnod `q3_2.txt` fájlban, ah
A sorbarendezés dokumentációját pedig ott találod: https://chillicream.com/docs/hotchocolate/v14/fetching-data/sorting
A válasz formátuma az alábbi legyen:
```json
{
"data": {
"orders": {
"edges": [
{
"node": {
"id": 5,
"orderItems": [
{
"amount": 2,
"product": {
"name": "Lego City harbour",
"price": 172268.75,
"stock": 12
}
},
{
"amount": 1,
"product": {
"name": "Activity playgim",
"price": 7488,
"stock": 21
}
}
]
}
}
]
}
}
}
```
!!! example "BEADANDÓ"
A módosított C# forráskódot töltsd fel.
Az 3. feladat első és második részében található lekérdezéseket mentsd le a `q3_1.txt` és `q3_2.txt` néven, tedd a képek mellé a gyökér mappába, és add le.
Expand Down

0 comments on commit 8ddf843

Please sign in to comment.