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
base: 05-05-refactor_experimental_graphql_group_schema_type_resolvers
Are you sure you want to change the base?
Conversation
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @buffalojoec and the rest of your teammates on Graphite |
5f9f41e
to
e14dfd1
Compare
2fe1d96
to
d400e65
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
if (onlyFieldsRequested(['slot'], info)) { | ||
return { slot }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
deactivationSlot: Block | ||
lastExtendedSlot: Block |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) {
// ...
}
I'm interested to know your thoughts on whether or not we should drink from this cup some more. |
As the linked issue describes, the GraphQL resolver sports full support for
nested
Account
queries wherever a field has typeAddress
. Instead ofdefining that field to simply be of type
Address
, it's defined with typeAccount
,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 withBlock
,to enable nested block queries in the same fashion.
Closes #1822.