Chess Game API Example

mutation newGame
Game

Create a game with the given players.

These rules apply:

  • The white player must be a human or an Android or a computer.
  • The black player must be a human or an Android or a computer.
  • The white player cannot be the same as the black player.
  • The Game will start with the initial board state.

Chess rules can be found here.
Returns the new game.

Arguments
whitePlayerId ID

ID [scalar]

The ID scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID.

API:
Chess Game GraphQL API

blackPlayerId ID

ID [scalar]

The ID scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID.

API:
Chess Game GraphQL API

Returns
Game

Game [object]

A chess game.

Attributes
id ID

The ID of the game.

startedAt Date

The date and time when the game started.

endedAt Date

The date and time when the game ended.

white String

The name of the white player.

Deprecated: Use whitePlayer instead.
whitePlayer Player

The white player.

black String

The name of the black player.

Deprecated: Use blackPlayer instead.
blackPlayer Player

The black player.

board ChessBoard

The current state of the chess board.

movesCount Int

The number of moves in the game.

moves String []

Get the last N moves of the game. Returns all moves if no argument is provided.

The winner of the game.

prize Float

The prize of the game.

API:
Chess Game GraphQL API
Examples
New game
Creates a chess game with minimal input provided
mutation newGame {
  newGame(input: { whitePlayerId: "1", blackPlayerId: "2"}) {
    id
    startedAt
    movesCount
  }
}
API:
Chess Game GraphQL API