Repository navigation
Expand file tree
/
Copy pathExamples.graphql
More file actions
97 lines (91 loc) · 2.57 KB
/
Copy pathExamples.graphql
File metadata and controls
97 lines (91 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# =============================================================================
# Beispiel-Queries fuer die HotChocolate Demo
# Einfach in Banana Cake Pop (http://localhost:5071/graphql) einfuegen
# =============================================================================
# -----------------------------------------------------------------------------
# 1) Alle Buecher mit Paging, Filter, Sortierung
# -----------------------------------------------------------------------------
query BooksPaged {
books(
first: 10
where: { genre: { eq: FANTASY } }
order: [{ publishedOn: DESC }]
) {
totalCount
pageInfo { hasNextPage endCursor }
nodes {
id
title
isbn
publishedOn
author {
id
fullName # Auflösung per DataLoader (keine N+1 Query!)
}
}
}
}
# -----------------------------------------------------------------------------
# 2) Einzelnes Buch
# -----------------------------------------------------------------------------
query BookById {
bookById(id: "PUT-GUID-HERE") {
id
title
author { fullName }
}
}
# -----------------------------------------------------------------------------
# 3) Autor mit allen Buechern
# -----------------------------------------------------------------------------
query AuthorWithBooks {
authorById(id: "11111111-1111-1111-1111-111111111111") {
id
fullName
books { # Grouped-DataLoader Batch
title
publishedOn
genre
}
}
}
# -----------------------------------------------------------------------------
# 4) Mutation: Buch anlegen
# -----------------------------------------------------------------------------
mutation AddBook {
addBook(input: {
title: "The Silmarillion"
isbn: "978-0-261-10273-6"
publishedOn: "1977-09-15"
pageCount: 365
genre: FANTASY
authorId: "11111111-1111-1111-1111-111111111111"
}) {
book {
id
title
author { fullName }
}
}
}
# -----------------------------------------------------------------------------
# 5) Mutation: Buch aktualisieren
# -----------------------------------------------------------------------------
mutation UpdateBook {
updateBook(input: {
id: "PUT-GUID-HERE"
pageCount: 420
}) {
book { id title pageCount }
}
}
# -----------------------------------------------------------------------------
# 6) Subscription: neue Buecher live empfangen
# -----------------------------------------------------------------------------
subscription OnBookAdded {
onBookAdded {
id
title
author { fullName }
}
}