-
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
Make language nodes immutable #1338
Conversation
Now we don't have to mutate the `InputValueDefinition` node after it's allocated.
Make all AST nodes "read-only" data structures
👍 Looks like a nice improvement to me, I want to check tomorrow to make sure it doesn't break graphql-client, but other than that, I think it's all clear! |
Somehow I thought I already merged this, but I didn't 😌 It's going to break graphql-client: I like the idea of a more stable AST structure, but I'm going to change the target of this PR to |
I'll look in to what it takes to make graphql-client not mutate nodes. We may need a more functional interface for manipulating ASTs. |
GraphQL-js has a really nice approach for this, I added a comment to the previous issue for improving AST manipulation: #455 (comment) |
There are still a few things to do before immutable nodes are really ready:
But this is a great first step, so merging into the dev branch! |
Make language nodes immutable
We have code in our client that "deep freezes" all AST nodes. I think we could eliminate that if we just made AST nodes immutable by default. I only found one place where the gem is mutating nodes, but I guess all those "writer" methods are public API, so this PR might only be good for a major version release.
I separated this PR to two commits because I think avoiding mutation internally has merit on its own.