fix: isolate document node snapshots - #33
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d865cb819
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return nil | ||
| } | ||
| clone := *directive | ||
| clone.Arguments = append([]Argument(nil), directive.Arguments...) |
There was a problem hiding this comment.
Preserve non-nil empty argument slices
When AppendDirective or ReplaceDirective is called without arguments, syntheticDirective deliberately stores a non-nil empty Arguments slice, but cloning it with append([]Argument(nil), directive.Arguments...) collapses that value to nil. This makes Nodes() observably change the directive rather than merely copy it: nil checks change and JSON encoding produces null instead of the previous []. Preserve the source slice's nilness while cloning it.
Useful? React with 👍 / 👎.
Summary
Document.Nodes()return fully independent node and directive snapshotsVerification
go test ./...go test -race ./...go vet ./...git diff --check