-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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: fix return types to be compatible with schema definition #26118
Conversation
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.
Thanks, LGTM!
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.
LGTM
Just noting here that this is a compatibility-breaking change. We've been returning hex-encoded strings from graphql for years, so there will likely be issues in some client software trying to parse these results. Maybe the schema should be changed instead? |
I think that we should update the version and release notes to indicate this. |
@s1na is in charge of the spec, so he'll be able to make a good decision here. |
IMO, if there is a spec, and we are not following it, then we're in the wrong and need to change it. |
I agree we should change these to decimal. Right now we have some fields that return a hex-encoded value, some that return decimal, all with a From discussion:
I think this intention prompted PRs such as #21883. At the time not all fields were converted. IMO we should do this now. In addition to the ones you converted there are also the |
It's weird, many of the methods defined for |
The api-spec does not mention or refer to |
The API specification (https://github.com/ethereum/execution-apis) was created only very recently, and we literally copied the existing GraphQL schema there without changing it. It would be good to get to the point where schema and responses align again, but keeping the de-facto API outputs stable should be preferred over changing the output to match the existing (but apparently wrong) schema. The GraphQL stance on versioning seems to be that
i.e. they recommend just adding new fields with a different type, which could then be requested. I guess, if we take that literally, the correct solution is adding new fields like |
We literally copied it over means it was not created recently. It's an old standard, and we have not been compliant. Graphql has always been schema-first, as opposed to out old json-rpc. Imo we are at liberty to ruthlessly pursue standard compliance for graphql, since it's newer and more schema-centric. So I still think we should just fix our erroneous behavior.
|
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.
sgtm (breaking users is fun)
|
@karalabe thanks for catching that. I've updated the PR |
The following job is failing but I dont think it is related to these changes. Could someone guide me on how to resolve this ?
|
Thats a flaky test, we can just ignore it. Not a showstopper for your pr |
Discussion result: Going back to the spec, we find that the definition of So a follow-up task is defining this better in the spec. If we choose to do it the way it's implemented in the PR, we should explicitly define |
We have already defined the custom scalar Long as an integer in our graphql server setup - https://github.com/ethereum/go-ethereum/blob/master/graphql/graphql.go#L45-L76 Do we wish to modify this and throw an error when base 10 strings are passed to unmarshal ? Or are you referring to something else ? |
My comment was mostly for @s1na, and was referring to the execution-apis spec: https://github.com/ethereum/execution-apis/blob/f33432b3a3f3d6de6ff5e7977f580376df9b57d9/graphql.json#L1226-L1235 |
@fjl thanks for the clarification. I think the ethereum API spec is correct as its the implementation's responsibility to ensure type validation
|
Yes, closing this as resolved. |
According to the schema definition and spec defined here, the transaction fields gas, nonce and the block field timestamp should be decimal.
This is inline with the other
Long
values liketransaction status
, etc