-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Language::Visitor] use method-based visit handlers #1290
Conversation
This is rad! ❤️I really love this change. |
This is a helpful change. |
I rewrote StaticValidation to use class-based visitor, I'm happy with the code and the perf is about the same
|
I pushed a little harder and re-wrote the remaining bits to use the new API, now it's a decent bit faster, 10% give or take.
|
I removed |
39bf163
to
8bf1e32
Compare
This is almost passing. We still need one more thing out of the new visitor API, a way to modify the AST that's being iterated over. But I will add that in a later PR, this is a big step forward as-is! |
[Language::Visitor] use method-based visit handlers
I'm thinking of stealing a page from the
parser
gem's book. There, the AST visitor is a class withon_*
handlers for each kind of AST node. It's really easy to get going, I'd like to do the same thing in GraphQL-Ruby.So, I tried the API on a couple of validation rules, and I'm going to try a few more. If it seems to work, I'll improve the support for that kind of API and deprecate the
[node_class] <<
API. I think we will need to useyield
orsuper
to support[node_class].leave <<
. (parser
usessuper
). Also, I'll be interested to see the performance impact.