Website: https://graphql-cricket-league-server.herokuapp.com/graphql
App contain simple access to Indian Premier League data by graphql queries. The basement
of application is Apollo Server
associated with Express.js
. There was used schema first
approach
during development process. Playground by apollo server is exposes because of presentation purposes.
Inside .db
folder you can find a csv files to fill tables with data. There were created special migrations
to automate this process (more inf in how to run). For finding the right match that you look for, trigrams
were implemented. There was created index (pg_trgm
module) which associate in match table between columns:
venueName, cityName and hostCountry. This approach make easier finding match by location.
- Copy
.env.template
to.env
in the same path. - Run
docker-compose up
If you find problem with migration you can lunch it by yourself npm run migration:up
or refresh server
to automatically execute migration commands. (Application sometimes try to run migrations commands before
full database initialization. To resolve it you can use upper approach or
use https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh or increase timeout for
database connection in app.)
query Matches($matchPlace: String!) {
matches(matchPlace: $matchPlace) {
cityName
hostCountry
venueName
id
matchDate
}
}
Pay attention to value ramchi
. There is an incorrect cityName because the correct
is Ranchi
by n not m. Trigrams make job on this query and try to
find the most
appropriate records for provided arguments.
{
"matchPlace": "ramchi"
}
{
"data": {
"matches": [
{
"cityName": "Ranchi",
"hostCountry": "India",
"venueName": "JSCA International Stadium Complex",
"id": 598062,
"matchDate": "2013-05-12"
},
...
]
}
}
query Players($playerId: Int!) {
player(playerId: $playerId) {
id
name
country
playedMatches {
isCaptain
isKeeper
team {
teamCode
teamName
}
match {
matchDate
cityName
hostCountry
season {
year
}
}
}
}
}
{
"playerId": 3
}
query Players($pagination: Pagination!) {
players(pagination: $pagination) {
name
dob
country
isUmpire
playedMatches {
match {
matchDate
season {
year
}
winType
cityName
hostCountry
}
isKeeper
isCaptain
team {
teamName
teamCode
}
}
battingHand
bowlingSkill
}
}
{
"pagination": {
"offset": 0,
"limit": 10
}
}
query Team($teamId: Int!) {
team(teamId: $teamId) {
id
teamCode
teamName
}
}
{
"teamId": 3
}
query Teams {
teams {
id
teamName
teamCode
}
}