Files
worldcup/lib/graphql/schema.ts
T
valknar 6e6e819718 fix: scope team page scorers by teamId instead of filtering global top 200
Teams with few goals (e.g. Qatar) were missing from the sidebar because
topScorers(limit:200) only returned all-time top scorers. Now the query
filters by teamId in SQL so every team shows their own scorers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 21:11:16 +02:00

200 lines
3.7 KiB
TypeScript

export const typeDefs = /* GraphQL */ `
type Tournament {
year: Int!
host: String!
winner: String
runnerUp: String
thirdPlace: String
fourthPlace: String
teamsCount: Int
matchesCount: Int
totalGoals: Int
avgGoalsPerGame: Float
topScorers(limit: Int): [ScorerEntry!]!
matches: [Match!]!
}
type Team {
id: Int!
name: String!
slug: String!
iso2: String
fifaCode: String
continent: String
confederation: String
stats: TeamStats
}
type TeamStats {
appearances: Int!
wins: Int!
draws: Int!
losses: Int!
goalsFor: Int!
goalsAgainst: Int!
goalDiff: Int!
titles: Int!
winPct: Float!
}
type Stadium {
id: Int!
tournamentYear: Int
name: String!
city: String
countryCode: String
capacity: Int
timezone: String
coordinates: String
matchCount: Int
}
type Match {
id: Int!
year: Int!
round: String!
group: String
date: String
time: String
stadium: String
team1: Team!
team2: Team!
scoreFt: [Int!]
scoreHt: [Int!]
scoreEt: [Int!]
scoreP: [Int!]
goals: [Goal!]!
isLive: Boolean!
isQualiPlayoff: Boolean!
margin: Int
totalGoals: Int
}
type Goal {
id: Int!
team: Team!
playerName: String!
minute: Int
minuteOffset: Int
isPenalty: Boolean!
isOwnGoal: Boolean!
}
type ScorerEntry {
playerName: String!
team: Team
goals: Int!
penalties: Int!
ownGoals: Int!
tournaments: Int!
}
type GroupStanding {
groupName: String!
pos: Int
team: Team!
played: Int!
won: Int!
drawn: Int!
lost: Int!
goalsFor: Int!
goalsAgainst: Int!
goalDiff: Int!
pts: Int!
}
type SquadPlayer {
playerName: String!
shirtNumber: Int
position: String
dateOfBirth: String
team: Team!
age: Int
}
type GlobalStats {
totalTournaments: Int!
totalMatches: Int!
totalGoals: Int!
avgGoalsPerGame: Float!
mostGoalsInTournament: TournamentGoalRecord
highestScoringMatch: Match
biggestWin: Match
mostTitles: ScorerEntry
}
type TournamentGoalRecord {
year: Int!
host: String!
totalGoals: Int!
}
type HatTrick {
playerName: String!
team: Team
year: Int!
round: String!
opponent: Team
goals: Int!
}
type MinuteBucket {
bucket: String!
count: Int!
}
type ConfederationStat {
confederation: String!
appearances: Int!
titles: Int!
totalGoals: Int!
}
type SearchResults {
tournaments: [Tournament!]!
teams: [Team!]!
players: [ScorerEntry!]!
matches: [Match!]!
}
type Query {
tournaments: [Tournament!]!
tournament(year: Int!): Tournament
matches(year: Int, group: String, round: String, isQuali: Boolean, teamId: Int): [Match!]!
match(id: Int!): Match
liveMatches: [Match!]!
recentMatches(limit: Int): [Match!]!
upcomingMatches(limit: Int): [Match!]!
teams: [Team!]!
team(slug: String!): Team
topScorers(year: Int, limit: Int, teamId: Int): [ScorerEntry!]!
player(name: String!): ScorerEntry
hatTricks(year: Int): [HatTrick!]!
groupStandings(year: Int!): [GroupStanding!]!
stadiums(year: Int): [Stadium!]!
squads(year: Int!, team: String): [SquadPlayer!]!
tournamentStats: GlobalStats!
goalsByMinute: [MinuteBucket!]!
confederationStats: [ConfederationStat!]!
biggestWins(limit: Int): [Match!]!
highestScoringMatches(limit: Int): [Match!]!
extraTimeStats: ExtraTimeStats!
search(query: String!): SearchResults!
}
type ExtraTimeStats {
totalKnockoutMatches: Int!
wentToExtraTime: Int!
wentToPenalties: Int!
extraTimePct: Float!
penaltiesPct: Float!
}
`