UNPKG

rune

Version:

CLI to upload your games to Rune

21 lines (20 loc) 683 B
import { client } from "../../apollo/client.js"; import { CreateGameDocument, GameType, } from "../../generated/types.js"; /** * Creates a new game on the Rune platform * @param game The game data to create * @returns A promise that resolves to the created game's ID */ export async function createGame(game) { const { data, errors } = await client.mutate({ mutation: CreateGameDocument, variables: { game: { ...game, type: GameType.MULTIPLAYER } }, }); if (errors && errors.length > 0) { throw errors[0]; } if (!data) { throw new Error("No data returned from createGame mutation"); } return data.createGame.game.id; }