Files
predavanja/Events.GraphQL/graphql-cheat-sheet.md
2026-05-12 20:41:06 +02:00

97 lines
1.1 KiB
Markdown

# GraphQL Cheat Sheet
Use endpoint: `/graphql`
## Available queries
- `countries`
- `sports`
- `people`
- `peoplePage(pageNumber, pageSize)`
- `events`
- `eventsForDate(date)`
- `registrations`
## Common arguments
- paging: `first`, `after`, `last`, `before`
- filtering: `where`
- sorting: `order`
## Quick examples
### Get events
```graphql
query {
events(first: 5) {
nodes {
id
name
eventDate
}
}
}
```
### Filter people by country
```graphql
query {
people(where: { countryCode: { eq: "HR" } }, first: 10) {
nodes {
id
firstName
lastName
}
}
}
```
### Sort sports by name
```graphql
query {
sports(order: [{ name: ASC }], first: 10) {
nodes {
id
name
}
}
}
```
### Events for a specific date
```graphql
query {
eventsForDate(date: "2026-06-15", first: 10) {
nodes {
id
name
}
}
}
```
### Classic paging with `peoplePage`
```graphql
query {
peoplePage(pageNumber: 1, pageSize: 5) {
totalCount
items {
id
firstName
lastName
}
}
}
```
## Mutations
- `addEvent(input)`
- `updateEvent(id, input)`
- `deleteEvent(id)`