Currently, the Agent query only supports searches by the agent's address.
However, users often need to find an agent by checking if a given avatarAddress exists in the AvatarAddresses field.
Modify the GraphQL Query class to include a parameter hasAvatarAddress and add the logic for searching using this new parameter.
example:
public async Task<AgentState> GetAgentAsync(
Address? address,
Address? hasAvatarAddress,
[Service] AgentRepository repo
)
{
if (address is not null)
{
return (await repo.GetByAddressAsync(address.Value)).Object;
}
else if (hasAvatarAddress is not null)
{
var agent = await repo.FindByAvatarAddressAsync(hasAvatarAddress.Value);
if (agent is null)
{
throw new ArgumentException($"No agent found with avatarAddress: {hasAvatarAddress}");
}
return agent.Object;
}
else
{
throw new ArgumentException("Either address or hasAvatarAddress must be provided.");
}
}
3. Setup Local Database
Refer to CONTRIBUTING.md: Follow the setup instructions in the repository to initialize a local database for Mimir.
Currently, the
Agent
query only supports searches by the agent'saddress
. However, users often need to find an agent by checking if a givenavatarAddress
exists in theAvatarAddresses
field.Desired Query Example:
Implementation Steps:
1. Update AgentRepository
Add a new method
FindByAvatarAddressAsync
to check if the givenavatarAddress
exists within theAvatarAddresses
field.example:
2. Update Query
Modify the GraphQL
Query
class to include a parameterhasAvatarAddress
and add the logic for searching using this new parameter.example:
3. Setup Local Database
CONTRIBUTING.md
: Follow the setup instructions in the repository to initialize a local database for Mimir.Populate the Database:
Example
agent
document for testing:Import this data into the
agent
4. Test Cases
Query by
hasAvatarAddress
:Expected Result: