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 slot-based nested queries #1822

Open
buffalojoec opened this issue Nov 10, 2023 · 1 comment
Open

[GraphQL]: Add support for slot-based nested queries #1822

buffalojoec opened this issue Nov 10, 2023 · 1 comment
Labels
enhancement New feature or request GraphQL
Milestone

Comments

@buffalojoec
Copy link
Collaborator

buffalojoec commented Nov 10, 2023

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: Lamports
    ownerProgram: Account
    space: BigInt
    rentEpoch: Epoch
    addresses: [Address]
    authority: Account
    deactivationSlot: Slot
    lastExtendedSlot: Slot
    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.

We can enable the same types of nested queries for block on any fields that are
populated with Slot.

Details

This is actually quite trivial to implement, given the relationship of type definitions
and resolvers defined in this library. Here's an example.

"""
A lookup table account
"""
type LookupTableAccount implements Account {
    address: Address
    data(encoding: AccountEncoding!, dataSlice: DataSlice): String
    executable: Boolean
    lamports: Lamports
    ownerProgram: Account
    space: BigInt
    rentEpoch: Epoch
    addresses: [Address]
    authority: Account
    deactivationSlot: Block   # `Block` type, instead of `Slot`
    lastExtendedSlot: Block   # `Block` type, instead of `Slot`
    lastExtendedSlotStartIndex: Int
}
LookupTableAccount: {
    authority: resolveAccount('authority'),
    data: resolveAccountData(),
    ownerProgram: resolveAccount('ownerProgram'),
    // Block resolvers hooked up.
    deactivationSlot: resolveBlock('deactivationSlot'),
    lastExtendedSlot: resolveBlock('lastExtendedSlot'),
},

The main question here is "should we do this?" and unless we can produce
salient arguments against it, I believe we should.

@buffalojoec buffalojoec added enhancement New feature or request GraphQL labels Nov 10, 2023
@buffalojoec

This comment was marked as resolved.

@buffalojoec buffalojoec added this to the GraphQL milestone Apr 2, 2024
@buffalojoec buffalojoec changed the title Add support for slot-based nested GraphQL queries [GraphQL]: Add support for slot-based nestedc queries Apr 2, 2024
@buffalojoec buffalojoec changed the title [GraphQL]: Add support for slot-based nestedc queries [GraphQL]: Add support for slot-based nested queries Apr 2, 2024
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