Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphQL]: Add support for fields with lists of accounts #2615

Open
buffalojoec opened this issue May 4, 2024 · 0 comments
Open

[GraphQL]: Add support for fields with lists of accounts #2615

buffalojoec opened this issue May 4, 2024 · 0 comments
Labels
enhancement New feature or request GraphQL
Milestone

Comments

@buffalojoec
Copy link
Collaborator

Motivation

Throughout the GraphQL schema, fields populated by an Address have been
given the type Account, which enabled nested queries on that address. Take,
for example, a lookup table account.

"""
A lookup table account
"""
type LookupTableAccount implements Account {
    address: Address
    data(encoding: AccountEncoding!, dataSlice: DataSlice): String
    executable: Boolean
    lamports: BigInt
    ownerProgram: Account
    space: BigInt
    rentEpoch: BigInt
    addresses: [Address]
    authority: Account
    deactivationSlot: String
    lastExtendedSlot: String
    lastExtendedSlotStartIndex: Int
}

You can see fields like ownerProgram and authority are queryable as
Account types, allowing full account queries to be performed on these nested
fields.

It would be nice to allow enable nested account querying for fields that have a
list of addresses, such as addresses in the lookup table above.

Details

Implementing this capability might seem trivial, but simply attaching a "multiple
accounts" resolver to the field is not enough.

LookupTableAccount: {
    authority: resolveAccount('authority'),
    data: resolveAccountData(),
    ownerProgram: resolveAccount('ownerProgram'),
    // Multiple accounts resolver.
    addresses: resolveMultipleAccounts('addresses'),
},

In a situation where a page may need to reload one account in the list, the above
solution would require the entire list of accounts to be re-loaded, rather than just
the account in question. As a result, we'll need to go a bit further to make sure this
new feature isn't prohibitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GraphQL
Projects
None yet
Development

No branches or pull requests

1 participant