Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

refactor(experimental-graphql): revise accounts schema (again) #1837

Conversation

buffalojoec
Copy link
Contributor

@buffalojoec buffalojoec commented Nov 12, 2023

This PR attempts to revise the accounts schema, as per #1831.

@mergify mergify bot added the community label Nov 12, 2023
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 2576806 to 6b0007e Compare November 12, 2023 13:02
@buffalojoec buffalojoec marked this pull request as ready for review November 12, 2023 13:24
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 6b0007e to 4bf0715 Compare November 12, 2023 13:24
@buffalojoec
Copy link
Contributor Author

We're still going to want to sort out this comment here from the previous PR. I'm not sure if blocking the ability to specify encoding for these nested accounts is the way.

Comment on lines +320 to 394
feeCalculator {
lamportsPerSignature
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tangent; this is hella deprecated right? Should we do something else here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, I didn't check if it was deprecated 😅

Something different, like, take it out completely?

Copy link
Contributor

Choose a reason for hiding this comment

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

Take it out if there's no non-deprecated way to get at it, or flatten it down to the same level as blockhash and give it a good name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I've been digging around and I don't see any evidence this is deprecated. Do you have any links? Also threw a flare up in Discord.

Copy link
Contributor

Choose a reason for hiding this comment

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

image

Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Returning this to your queue for some questions!

queuepatrick

@buffalojoec
Copy link
Contributor Author

Returning this to your queue for some questions!

OK, I pushed up a revised version! Lmk what you think.

@buffalojoec buffalojoec changed the base branch from master to 11-15-refactor_experimental-graphql_roll_some_new_type_aliases November 15, 2023 16:53
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 4bf0715 to 9b11e3c Compare November 15, 2023 16:53
@buffalojoec buffalojoec force-pushed the 11-15-refactor_experimental-graphql_roll_some_new_type_aliases branch from 1781287 to 4888367 Compare November 15, 2023 20:32
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 9b11e3c to 97ae5ba Compare November 15, 2023 20:32
@buffalojoec buffalojoec force-pushed the 11-15-refactor_experimental-graphql_roll_some_new_type_aliases branch from 4888367 to 3348cdc Compare November 16, 2023 19:30
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 97ae5ba to 0135a4d Compare November 16, 2023 19:30
Base automatically changed from 11-15-refactor_experimental-graphql_roll_some_new_type_aliases to master November 21, 2023 10:49
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 0135a4d to f6ed442 Compare November 21, 2023 12:02
Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

giphy.gif

I would really eliminate encoding from the account field entirely, and bury all that complexity in the resolvers. Either way, you could rip out encoding in a separate PR.

Let me know if you want to do a call to talk about how this would actually be implemented.

@@ -304,14 +310,11 @@ describe('account', () => {
const source = /* GraphQL */ `
query testQuery($address: String!) {
account(address: $address, encoding: PARSED) {
Copy link
Contributor

@steveluscher steveluscher Nov 28, 2023

Choose a reason for hiding this comment

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

So, here's how I think about this.

People should just straight up not be bothered with these fetch modes. It should just never surface in the GraphQL API.

I should absolutely not give a shit about specifying an encoding, I should just do this.

account(address: "123") {
  ... on MintAccount {
    supply
  }
}

…and if that requires that we ask the RPC to parse the data using the jsonParsed mode, so be it.

To be pedantic, if we detect the presence of subselections in the query that we can't possibly fulfil except by fetching the thing in jsonParsed mode, then we should fetch the account in jsonParsed mode. Otherwise, we shouldn't.

If I really want the underlying buffer, then we can offer this:

account(address: "123") {
  data(encoding: BASE64)
}

Then we fetch it with the base64 encoding.

What if someone does this totally legal query?

account(address: "123") {
  compressedBase64Data: data(encoding: BASE64_ZSTD)
  base64Data: data(encoding: BASE64)
  ... on MintAccount {
    supply
  }
}

Yep. We have to make that underlying fetch three times with the current JSON RPC API.

Except when we rewrite the RPC, we can make this more efficient, and get all of the data in one shot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, I like this. jsonParsed is already the default here, so you don't need to specify any encodings unless you want a buffer, but this is a much better way to handle the encoded stuff. Nice.

Will definitely roll this into a new PR.

Comment on lines +320 to 394
feeCalculator {
lamportsPerSignature
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Take it out if there's no non-deprecated way to get at it, or flatten it down to the same level as blockhash and give it a good name.

Comment on lines 172 to 173
... on AccountBase64Zstd {
address
data
executable
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Much preferable to do data(encoding: AccountEncoding).

@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from f6ed442 to 4f4f790 Compare November 28, 2023 13:15
@buffalojoec buffalojoec force-pushed the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch from 4f4f790 to d78cf2d Compare November 28, 2023 13:18
Copy link
Contributor Author

buffalojoec commented Nov 28, 2023

Merge activity

@buffalojoec buffalojoec merged commit 1b12bd3 into master Nov 28, 2023
6 checks passed
@buffalojoec buffalojoec deleted the 11-12-refactor_experimental-graphql_revise_accounts_schema_again_ branch November 28, 2023 13:18
Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants