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

refactor(experimental): graphql: slot-based nested queries #2643

Open
wants to merge 1 commit into
base: 05-05-refactor_experimental_graphql_group_schema_type_resolvers
Choose a base branch
from

Conversation

buffalojoec
Copy link
Collaborator

@buffalojoec buffalojoec commented May 6, 2024

As the linked issue describes, the GraphQL resolver sports full support for
nested Account queries wherever a field has type Address. Instead of
defining that field to simply be of type Address, it's defined with type Account,
which enables nested account queries on that field based on the address
returned.

In this PR, we're taking every field with type Slot and replacing it with Block,
to enable nested block queries in the same fashion.

Closes #1822.

Copy link

changeset-bot bot commented May 6, 2024

⚠️ No Changeset found

Latest commit: d400e65

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator Author

buffalojoec commented May 6, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @buffalojoec and the rest of your teammates on Graphite Graphite

@buffalojoec buffalojoec force-pushed the 05-05-refactor_experimental_graphql_group_schema_type_resolvers branch from 5f9f41e to e14dfd1 Compare May 6, 2024 12:51
@buffalojoec buffalojoec force-pushed the 05-05-refactor_experimental_graphql_slot-based_nested_queries branch from 2fe1d96 to d400e65 Compare May 6, 2024 12:52
@buffalojoec buffalojoec marked this pull request as ready for review May 6, 2024 12:52
Copy link
Collaborator

@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.

I think if we're going to drink deep from this cup, we should probably rename everything to reflect the return type.

@@ -55,7 +61,9 @@ describe('account loader', () => {
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
slot
slot {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't this need to be renamed to block then, to reflect the new return type?

Comment on lines 27 to 29
if (onlyFieldsRequested(['slot'], info)) {
return { slot };
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this behave if I do:

{
    block: {
        __id
        __type
        slot
    }
}

Relay, for instance, basically adds __id and __type to every subselection automatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah GraphQL-JS adds those!

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I mean to ask is if this resolver will get deopted (ie. make the fetch) if the client asks for __id and __type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ohhh yeah it might actually. I'll add a PR for this. Good call.

Comment on lines +60 to +61
deactivationSlot: Block
lastExtendedSlot: Block
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still think these should be renamed to reflect the new return type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I truly waffled on this a bit actually. I just wanted to be careful about straying too far from the defined data, such as an account whose fields are "something-slot" and now they have to call it "block".

I couldn't decide if this was acceptable, really.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we leave it this way, it's going to lead to a lot of aggravating code like:

if (data.slot.slot < 123n) {
    // ...
}

@buffalojoec
Copy link
Collaborator Author

I think if we're going to drink deep from this cup, we should probably rename everything to reflect the return type.

I'm interested to know your thoughts on whether or not we should drink from this cup some more.

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.

None yet

2 participants