forked from leuchter/VS_LET
31 lines
4.2 KiB
Markdown
31 lines
4.2 KiB
Markdown
# GraphQL Queries
|
|
|
|
``just serve``
|
|
|
|
- zuerst einige Stimmen über das Servlet abgeben: ["Howard Joel Wolowitz" wählen](http://localhost:8080/vote?action=vote&alternative=Howard+Joel+Wolowitz)
|
|
- dann einige Stimmen weitere über das Servlet abgeben: ["Dr. Amy Farrah Fowler" wählen](http://localhost:8080/vote?action=vote&alternative=Dr.+Amy+Farrah+Fowler)
|
|
- über das Servlet abfragen, wie gewählt wurde: [Ergebnis abrufen](http://localhost:8080/vote?action=print)
|
|
|
|
## GraphiQL-UI
|
|
|
|
[http://localhost:8080/graphiql/](http://localhost:8080/graphiql/)
|
|
|
|
## GraphQL-Queries
|
|
- Anzahl aller abgegebenen Stimmen: [``{votesNumber}``](http://localhost:8080/graphiql/?query=%23%20Anzahl%20aller%20abgegebenen%20Stimmen%0A%7B%0A%20%20votesNumber%0A%7D%0A)
|
|
- alle Stimmen: [``{allVotes {choice votes}}``](http://localhost:8080/graphiql/?query=%23%20alle%20Stimmen%3A%20%0Aquery%20%7B%0A%20%20allVotes%20%7B%0A%20%20%20%20choice%0A%20%20%20%20votes%0A%20%20%7D%0A%7D%0A)
|
|
- alle Stimmen, nur die Namen: [``{allVotes {choice}}``](http://localhost:8080/graphiql/?query=%23%20alle%20Stimmen%2C%20nur%20die%20Namen%3A%20%0Aquery%20%7B%0A%20%20allVotes%20%7B%0A%20%20%20%20choice%0A%20%20%7D%0A%7D%0A)
|
|
- Anzahl der Stimmen für "Dr. Amy Farrah Fowler": [``{votes(choice: "Dr. Amy Farrah Fowler")}``](http://localhost:8080/graphiql/?query=%23%20Anzahl%20der%20Stimmen%20f%C3%BCr%20%22Dr.%20Amy%20Farrah%20Fowler%22%3A%20%0A%7B%0A%20%20votes(choice%3A%20%22Dr.%20Amy%20Farrah%20Fowler%22)%0A%7D%0A)
|
|
- mit nicht gewähltem Namen geht es auch (Ergebnis = 0): [``{votes(choice: "Lex Luthor")}``](http://localhost:8080/graphiql/?query=%23%20mit%20nicht%20gew%C3%A4hltem%20Namen%20geht%20es%20auch%20(Ergebnis%20%3D%200)%3A%20%0A%7B%0A%20%20votes(choice%3A%20%22Lex%20Luthor%22)%0A%7D%0A)
|
|
- ohne Namen geht es nicht (Pflichtfeld): [``{votes()}``](http://localhost:8080/graphiql/?query=%23%20ohne%20Namen%20geht%20es%20nicht%20(Pflichtfeld)%3A%20%0Aquery%20%7Bvotes()%7D)
|
|
|
|
## ändernde GraphQL-Queries *("Mutation")*
|
|
|
|
- Mutation: Stimme für Superman abgeben: [``mutation {vote(choice: "Clark Kent")}``](http://localhost:8080/graphiql/?query=%23%20Mutation%3A%20Stimme%20f%C3%BCr%20Superman%20abgeben%3A%0Amutation%20%7B%0A%20%20vote(choice%3A%20%22Clark%20Kent%22)%0A%7D%0A)
|
|
- alle Stimmen, jetzt mit Clark Kent: [``{allVotes {choice votes}}``](http://localhost:8080/graphiql/?query=%23%20alle%20Stimmen%2C%20jetzt%20mit%20Clark%20Kent%3A%0Aquery%20%7B%0A%20%20allVotes%20%7B%0A%20%20%20%20choice%0A%20%20%20%20votes%0A%20%20%7D%0A%7D%0A)
|
|
- Fehler: Anzahl Parameter falsch: [``mutation {vote(choice: "Clark Kent", votes: 42)}``](http://localhost:8080/graphiql/?query=%23%20Fehler%3A%20Anzahl%20Parameter%20falsch%3A%20%0Amutation%20%7B%0A%20%20vote(choice%3A%20%22Clark%20Kent%22%2C%20votes%3A%2042)%0A%7D%0A)
|
|
- Mutation: Datensatz ändern: [``mutation {cheat(choice: "Clark Kent" votes:43){choice}}``](http://localhost:8080/graphiql/?query=%23%20Mutation%3A%20Datensatz%20%C3%A4ndern%3A%0Amutation%20%7B%0A%20%20cheat(choice%3A%20%22Clark%20Kent%22%2C%20votes%3A%2043)%20%7B%0A%20%20%20%20choice%0A%20%20%7D%0A%7D%0A)
|
|
- Mutation: Datensatz ändern und Ergebnis-Datensatz sehen: [``mutation {cheat(choice: "Clark Kent", votes: 42){choice votes}}``](http://localhost:8080/graphiql/?query=%23%20Mutation%3A%20Datensatz%20%C3%A4ndern%20und%20Ergebnis-Datensatz%20sehen%3A%0Amutation%20%7B%0A%20%20cheat(choice%3A%20%22Clark%20Kent%22%2C%20votes%3A%2042)%20%7B%0A%20%20%20%20choice%0A%20%20%20%20votes%0A%20%20%7D%0A%7D%0A)
|
|
- alle Stimmen, Anzahl Stimmen von Clark Kent geändert: [``{allVotes {choice votes}}``](http://localhost:8080/graphiql/?query=%23%20alle%20Stimmen%2C%20Anzahl%20Stimmen%20von%20Clark%20Kent%20ge%C3%A4ndert%3A%0A%7B%0A%20%20allVotes%20%7B%0A%20%20%20%20choice%0A%20%20%20%20votes%0A%20%20%7D%0A%7D%0A)
|
|
- Mutation: Datensatz neu eintragen: [``mutation {cheat(choice: "Bruce Wayne", votes: 42){choice}}``](http://localhost:8080/graphiql/?query=%23%20Mutation%3A%20Datensatz%20neu%20eintragen%3A%0Amutation%20%7B%0A%20%20cheat(choice%3A%20%22Bruce%20Wayne%22%2C%20votes%3A%2042)%20%7B%0A%20%20%20%20choice%0A%20%20%7D%0A%7D%0A)
|
|
- alle Stimmen: [``{allVotes {choice votes}}``](http://localhost:8080/graphiql/?query=%23%20alle%20Stimmen%3A%0A%7B%0A%20%20allVotes%20%7B%0A%20%20%20%20choice%0A%20%20%20%20votes%0A%20%20%7D%0A%7D%0A)
|