Skip to content

Commit 3a144ee

Browse files
committed
Add query for fetching all of a user's picks
1 parent 43cdb5e commit 3a144ee

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

connection-pool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class PGDB extends SQLDataSource {
208208
'league_id': leagueID,
209209
'invalidated_at': null
210210
})
211-
.cache(MINUTE);
211+
.cache(NOTHING);
212212
return val;
213213
}
214214

resolvers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ const resolvers = {
8282
console.log(err.stack);
8383
}
8484
},
85+
async picksForUser(parent, {leagueID, userID}, { dataSources }, info) {
86+
try {
87+
const result = await dataSources.pg.getPicksForMember(userID, leagueID);
88+
return result.map(function(row) {
89+
return pickFromRow(row);
90+
});
91+
} catch (err) {
92+
console.log(err.stack);
93+
}
94+
},
8595
async currentSeason(parent, {league}) {
8696
return process.env.CURRENT_SEASON;
8797
}

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ type Query {
111111
league(leagueID: ID!): FantasyLeague
112112
leagues(userID: String): [FantasyLeague!]
113113
currentPick(leagueID: ID!, userID: ID!): [Pick!]
114+
picksForUser(leagueID: ID!, userID: ID!): [Pick!]
114115
sportsTeams(league: SportsLeague): [SportsTeam!]
115116
sportsGames(league: SportsLeague, season: String, week: Int): [SportsGame!]
116117
currentSeason(league: SportsLeague): String

0 commit comments

Comments
 (0)