I am new to GraphQL and I am struggling to understand how to access / reference a table in the same logical way that I would approach a normal SQL query. I have created a docker container for postgres and I have initialized the database with a simple table of data.
To create the table, I ran this in my \init
directory. (Running Windows btw)
CREATE TABLE fda.nfl (
"team" TEXT,
"conference" TEXT,
"division" TEXT,
"city" TEXT,
"wins" INT,
"losses" INT,
"ties" INT
);
In GraphiQL, I can simply select everything with this query:
{
allNfls {
edges {
node {
team
conference
division
city
wins
losses
ties
}
}
}
}
I want to run something that can aggregate vertically and horizontally, e.g. sum(losses) as total_losses
or (wins / (wins + losses + ties)) as win_ratio
. I am unsure how to go about either of those scenarios with GraphQL. I would also need to query on certain conditions, but passing in a column name as an argument to node
does not seem to work, i.e. node(team: "Chiefs")
spits back an error about type allNfls
Is referencing a Postgres table like this in GraphQL even possible?