Create a battle
To start a new battle, thecreateBattle mutation should be executed. It accepts two required arguments:
| Argument | Type | Description |
|---|---|---|
domainId | ID | ID of a domain term associated with the battle. The list of the questions will be randomly generated based on the selected domain. To get the list of available options, call the getPossibleBattleOpponents query. |
opponentUserContextId | ID | ID of a user context associated with an opponent. To get the list of available options, call the getBattleDomains query. |
Battle object will be returned.
The initiator’s attempt will be created automatically when a new battle is created.
This means that the user can immediately proceed with the take battle flow.
Get available domains
To get the list of allowed domains that contain an appropriate number of questions, thegetBattleDomains query should be executed. The query returns the list of TaxonomyTerm
objects, sorted according to their weight configured in the backoffice:
Get possible opponents
A battle can be initiated only between two user contexts assigned to the same hierarchy level. The list of possible opponents can be retrieved by calling thegetPossibleBattleOpponents query.
Results will be returned with the pagination, sorted by the user context label,
and possibility to change the order (default sort order is ascending).
The following arguments can be used:
| Argument | Type | Description | Default |
|---|---|---|---|
after | Cursor | Returns results that come after the specified cursor. Should be used together with first parameter. Cannot be used if before is set. | — |
before | Cursor | Returns results that come before the specified cursor. Should be used together with last parameter. Cannot be used if after is set. | — |
first | Int | Returns up to the first N elements from the list. Required if after parameter is set. Cannot be used together with last. | — |
last | Int | Returns up to the first N elements from the list. Required if before parameter is set. Cannot be used together with first. | — |
name | String | Allows to search by the user context label. It makes sense to use it only if the real names are sent to the API during the user context data synchronization. | — |
reverse | Boolean | Allows to reverse the order of the underlying list (default order is ascending). | false |
BattleRival objects:
Related Features
Pagination
Learn how to efficiently navigate through large sets of items using cursor-based pagination.
Take a battle
Now, when the initiator’s attempt is created, the user can take the battle.