# Queries
In this section, you will discover queries. They are one of two primary objects handled by modules. Make sure to be all set up by reading the previous sections:
A query is a request for information made by end-users of an application through an interface and processed by a full node. Available information includes:
- Information about the network
- Information about the application itself
- Information about the application state
Queries do not require consensus to be processed as they do not trigger state transitions. Therefore, queries can be fully handled independently by a full node.
Visit the detailed Cosmos SDK documentation (opens new window) to get a clear overview of the query lifecycle and learn how a query is created, handled, and responded to.
# Next up
You can now continue with the next section if you want to skip ahead to read up on events.
If you prefer to see some code in action and continue with the checkers blockchain, take a look at the expandable box beneath.
If you have used Starport so far, it has already created queries for you to get one stored game or a list of them. You still do not have a way to check whether a move works/is valid. It would be wasteful to send a transaction with an invalid move. It is better to catch such a mistake before submitting a transaction. So you are going to create a query to know whether a move is valid.
Starport can again help you with a simple command:
This creates the query objects:
It also creates a function that should looks familiar:
So now you are left with filling in the gaps under TODO
. Simply put:
Is the game finished? You should add a
Winner
to yourStoredGame
first.Is it an expected player?
Is it the player's turn?
Attempt the move in memory without committing any new state:
If all checks passed, return the OK status:
Note that the player's move will be tested against the latest validated state of the blockchain. It does not test against the intermediate state being calculated as transactions are delivered, nor does it test against the potential state that would result from delivering the transactions still in the transaction pool.
A player can test their move only once the opponent's move is included in a previous block. These types of edge-case scenarios are not common in your checkers game and you can expect little to no effect on the user experience.
This is not an exhaustive list of potential queries. Some examples of other possible queries would be to get a player's open games or to get a list of games that are timing out soon. It depends on the needs of your application and how much functionality you willingly provide.