Skip to content

feat: /users/:address/permissions endpoint returning all lands permissions of a given user#440

Draft
aleortega wants to merge 6 commits intomainfrom
feat/all-lands-permissions-from-users
Draft

feat: /users/:address/permissions endpoint returning all lands permissions of a given user#440
aleortega wants to merge 6 commits intomainfrom
feat/all-lands-permissions-from-users

Conversation

@aleortega
Copy link
Member

@aleortega aleortega commented Oct 24, 2025

Introduced a comprehensive permissions endpoint /users/:address/permissions that returns all five permission types (owner, estateOwner, updateOperator, estateUpdateOperator, updateManager) for a given user. This consolidates ownership and operator data into a single response, with each parcel showing all applicable permission types and optional estate information.

Deprecated: /users/:address/lands-permissions now returns a Deprecation header and only provides the legacy updateOperator permissions format.

@coveralls
Copy link

coveralls commented Oct 24, 2025

Coverage Status

coverage: 80.532% (+0.2%) from 80.33%
when pulling ffe6dad on feat/all-lands-permissions-from-users
into 9a988c7 on main.

@aleortega aleortega marked this pull request as ready for review October 27, 2025 15:05
@aleortega aleortega force-pushed the feat/all-lands-permissions-from-users branch 3 times, most recently from 2987f9b to cd8194e Compare October 27, 2025 19:50
@aleortega aleortega force-pushed the feat/all-lands-permissions-from-users branch from cd8194e to ffe6dad Compare October 27, 2025 19:51
@aleortega aleortega changed the title feat: extends /users/:address/lands to return all permissions when includesAll query-param is provided feat: /users/:address/permissions endpoint returning all lands permissions of a given user Oct 28, 2025
query GetAllUserPermissions($address: String!) {
# 1. Direct parcel and estate ownership
user: wallet(id: $address) {
parcels {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to have this into mind, users with more than the maximum amount of retrievable entries might have less results returned.

}

# 4. Address-level UpdateManager permissions
updateManagerAuthorizations: authorizations(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authorizations graph has a history of the authorizations given to the user. It records each authorization action, either to give the authorization or to remove it. In order to know which parcels or estates are authorized, we need to go through the authorization's list and compute it. Would you mind changing that?

first: 1000
) {
owner {
parcels {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parcels and estates returned here are parcels and estates the user owns. These come from the Wallet entity which is linked to the Parcel and Estate entities via the owner property.
What we would like to return from this query is the complete list of authorizations to compute both the updateManager and approvedForAll authorizations. Would you mind changing that?


# 3. Estate-level UpdateOperator permissions
updateOperatorEstates: estates(
where: { updateOperator: $address }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the updateOperator and the operator for estates, we should retrieve all estates that match any of these properties, would you mind changing the query to match that?

}

# 3. Estate-level UpdateOperator permissions
updateOperatorEstates: estates(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create queries to get the parcels for uses that own, are update operators or operators of the asset:

query ($address: String) {
  parcels(first: 100, where: { or: [{ owner: $address }, { updateOperator:$address }, { operator: $address }] }) {
    x
    y
    owner {
    	id
  	}
    updateOperator
    operator
  }
}

The same can be done for parcels belonging to estates.

x: acc.x,
y: acc.y,
permissions: Array.from(acc.permissions).sort(), // Sort for consistent ordering
estate: acc.estate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not wrong, parcels from the same estate will have the estate object replicated, which has the id and the size of the estate. Should we only return its id to avoid replicating the size?

id
size
owner { id }
parcels {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a derived parameter, I'm not sure if it's going to return are parcels that belong to this estate. Do we know if that's possible?

@aleortega aleortega marked this pull request as draft November 5, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants