feat: add api query to get tournament open for registeration

This commit is contained in:
MTG2000
2022-09-19 11:13:49 +03:00
parent a24d94f4b4
commit fa8c74b8de
7 changed files with 99 additions and 25 deletions

View File

@@ -613,6 +613,7 @@ export interface NexusGenFieldTypes {
getProject: NexusGenRootTypes['Project']; // Project!
getProjectsInTournament: NexusGenRootTypes['TournamentProjectsResponse']; // TournamentProjectsResponse!
getTournamentById: NexusGenRootTypes['Tournament']; // Tournament!
getTournamentToRegister: NexusGenRootTypes['Tournament'][]; // [Tournament!]!
getTrendingPosts: NexusGenRootTypes['Post'][]; // [Post!]!
hottestProjects: NexusGenRootTypes['Project'][]; // [Project!]!
me: NexusGenRootTypes['MyProfile'] | null; // MyProfile
@@ -996,6 +997,7 @@ export interface NexusGenFieldTypeNames {
getProject: 'Project'
getProjectsInTournament: 'TournamentProjectsResponse'
getTournamentById: 'Tournament'
getTournamentToRegister: 'Tournament'
getTrendingPosts: 'Post'
hottestProjects: 'Project'
me: 'MyProfile'

View File

@@ -333,6 +333,7 @@ type Query {
getProject(id: Int!): Project!
getProjectsInTournament(roleId: Int, search: String, skip: Int = 0, take: Int = 10, tournamentId: Int!): TournamentProjectsResponse!
getTournamentById(id: Int!): Tournament!
getTournamentToRegister: [Tournament!]!
getTrendingPosts: [Post!]!
hottestProjects(skip: Int = 0, take: Int = 50): [Project!]!
me: MyProfile

View File

@@ -214,6 +214,28 @@ const getTournamentById = extendType({
}
})
const getTournamentToRegister = extendType({
type: "Query",
definition(t) {
t.nonNull.list.nonNull.field('getTournamentToRegister', {
type: Tournament,
args: {
},
resolve() {
return prisma.tournament.findMany({
where: {
end_date: {
gt: new Date()
},
}
})
}
})
}
})
const ParticipationInfo = objectType({
name: "ParticipationInfo",
definition(t) {
@@ -538,6 +560,7 @@ module.exports = {
getMakersInTournament,
getProjectsInTournament,
tournamentParticipationInfo,
getTournamentToRegister,
// Mutations
registerInTournament,