diff --git a/graphql-schemas/detailedtournament.js b/graphql-schemas/detailedtournament.js index b2b484d0f..1b9669410 100644 --- a/graphql-schemas/detailedtournament.js +++ b/graphql-schemas/detailedtournament.js @@ -1,14 +1,12 @@ const { UserInputError, gql } = require("apollo-server-express") -const Tournament = require("../mongoose-models/tournament") -const Round = require("../mongoose-models/round") +const DetailedTournament = require("../mongoose-models/detailedtournament") +const DetailedSet = require("../mongoose-models/detailedset") const typeDef = gql` - extend type Query {} - extend type Mutation { - addTournament( + addDetailedTournament( tournament: DetailedTournamentInput! - rounds: [DetailedRoundInput!]! + sets: [DetailedSetInput!]! lanistaToken: String! ): Boolean! } @@ -17,7 +15,15 @@ const typeDef = gql` name: String! bracket_url: String! date: String! - top_3_team_names: [[String]!]! + top_3_team_names: [String!]! + top_3_discord_ids: [[String]!]! + } + + type DetailedTournament { + name: String! + bracket_url: String! + date: String! + top_3_team_names: [String!]! top_3_discord_ids: [[String]!]! } @@ -27,16 +33,8 @@ const typeDef = gql` stage: String! mode: Mode! duration: Int! - winners: TeamInfo! - losers: TeamInfo! - } - - type DetailedTournament { - name: String! - bracket_url: String! - date: String! - top_3_team_names: [[String]!]! - top_3_discord_ids: [[String]!]! + winners: TeamInfoInput! + losers: TeamInfoInput! } type DetailedSet { @@ -51,6 +49,12 @@ const typeDef = gql` losers: TeamInfo! } + input TeamInfoInput { + team_name: String! + players: [DetailedPlayerInput!]! + score: Int! + } + type TeamInfo { team_name: String! players: [DetailedPlayer!]! @@ -58,6 +62,19 @@ const typeDef = gql` score: Int! } + input DetailedPlayerInput { + discord_id: String! + weapon: String! + main_abilities: [Ability]! + sub_abilities: [Ability]! + kills: Int! + assists: Int! + deaths: Int! + specials: Int! + paint: Int! + gear: [String]! + } + type DetailedPlayer { discord_id: String! weapon: String! @@ -84,10 +101,21 @@ const typeDef = gql` ` const resolvers = { - Query: {}, + Mutation: { + addDetailedTournament: async (root, args) => { + console.log("args", args) + }, + }, } module.exports = { DetailedTournament: typeDef, detailedTournamentResolvers: resolvers, } + +/*{"tournament": {"name": "Test Tournament #1", "bracket_url": "www.google.com", "date": "1585006225", "top_3_team_names": ["Team 1", "Team 2", "Team 3"] "top_3_discord_ids": [["123", "123", "123", "123"], ["123", "123", "123", "123"], ["123", "123", "123", "123"]]}, "sets": {"round_number": 1, "game_number: 1, stage: "The Reef", mode: "SZ", duration: 300, winners: {"team_name": "Cool Team", players: [{"discord_id": "123", "weapon": "Tentatek Splattershot", "main_abilities": ["ISM", "ISM", "ISM"], "sub_abilities": ["ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM"], "kills": 1, "assists": 1, "deaths": 1, "specials": 1, "paint": 1000, "gear": ["asd", "asd", "asd"]}], "score": 100}, losers: {"team_name": "Cool Team", players: [{"discord_id": "123", "weapon": "Tentatek Splattershot", "main_abilities": ["ISM", "ISM", "ISM"], "sub_abilities": ["ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM"], "kills": 1, "assists": 1, "deaths": 1, "specials": 1, "paint": 1000, "gear": ["asd", "asd", "asd"]}], "score": 100}}, "lanistaToken": "asd"} + + + +//player +{"team_name": "Cool Team", players: [{"discord_id": "123", "weapon": "Tentatek Splattershot", "main_abilities": ["ISM", "ISM", "ISM"], "sub_abilities": ["ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM", "ISM"], "kills": 1, "assists": 1, "deaths": 1, "specials": 1, "paint": 1000, "gear": ["asd", "asd", "asd"]}], "score": 100}*/ diff --git a/mongoose-models/detailedset.js b/mongoose-models/detailedset.js new file mode 100644 index 000000000..b86c67afe --- /dev/null +++ b/mongoose-models/detailedset.js @@ -0,0 +1,36 @@ +const mongoose = require("mongoose") + +const Player = { + discord_id: String, + weapon: String, + main_abilities: [String], + sub_abilities: [String], + kills: Number, + assists: Number, + deaths: Number, + specials: Number, + paint: Number, + gear: [String], +} + +const TeamInfo = { + team_name: String, + players: [Player], + score: Number, +} + +const detailedSetSchema = new mongoose.Schema({ + tournament_id: { + type: mongoose.Schema.Types.ObjectId, + ref: "DetailedTournament", + }, + round_number: Number, + game_number: Number, + stage: String, + mode: String, + duration: Number, + winners: TeamInfo, + losers: TeamInfo, +}) + +module.exports = mongoose.model("DetailedSet", detailedSetSchema) diff --git a/mongoose-models/detailedtournament.js b/mongoose-models/detailedtournament.js new file mode 100644 index 000000000..8c2685717 --- /dev/null +++ b/mongoose-models/detailedtournament.js @@ -0,0 +1,11 @@ +const mongoose = require("mongoose") + +const detailedTournamentSchema = new mongoose.Schema({ + name: String, + bracket_url: String, + date: Date, + top_3_team_names: [[String]], + top_3_discord_ids: [[String]], +}) + +module.exports = mongoose.model("DetailedTournament", detailedTournamentSchema) diff --git a/schema.js b/schema.js index 6f2d66e37..adca95701 100644 --- a/schema.js +++ b/schema.js @@ -14,6 +14,10 @@ const { Tournament, tournamentResolvers, } = require("./graphql-schemas/tournament") +const { + DetailedTournament, + detailedTournamentResolvers, +} = require("./graphql-schemas/detailedtournament") const { FAPost, faPostResolvers } = require("./graphql-schemas/fapost") const { Plus, plusResolvers } = require("./graphql-schemas/plus") const { Team, teamResolvers } = require("./graphql-schemas/team") @@ -46,6 +50,7 @@ const schema = makeExecutableSchema({ Link, Trend, Tournament, + DetailedTournament, FAPost, Plus, Team, @@ -62,6 +67,7 @@ const schema = makeExecutableSchema({ linkResolvers, trendResolvers, tournamentResolvers, + detailedTournamentResolvers, faPostResolvers, plusResolvers, teamResolvers,