Skip to content

Add GraphQL/ContextWriteInType cop#183

Merged
DmitryTsepelev merged 3 commits intoDmitryTsepelev:masterfrom
smathieu:claude/add-rubocop-cop-P1NnD
Feb 14, 2026
Merged

Add GraphQL/ContextWriteInType cop#183
DmitryTsepelev merged 3 commits intoDmitryTsepelev:masterfrom
smathieu:claude/add-rubocop-cop-P1NnD

Conversation

@smathieu
Copy link
Contributor

@smathieu smathieu commented Feb 7, 2026

Add a new cop that detects writes to the context object in GraphQL type definitions. Writing to context mutates shared state across the query execution, which can lead to unexpected behavior.

The cop detects context[]=, context.merge!, and context.store calls. It is disabled by default and scoped to type files.

This is currently Disabled by default as it's a breaking change, but could be added to the list of on by default cops.

I think mutating the context in type is very error prone and should be avoided. I figured this should live in this gem, rather than just our code base.

Add a new cop that detects writes to the `context` object in GraphQL
type definitions. Writing to `context` mutates shared state across the
query execution, which can lead to unexpected behavior.

The cop detects `context[]=`, `context.merge!`, and `context.store`
calls. It is disabled by default and scoped to type files.

https://claude.ai/code/session_014TRTLxSorVoijGQoDJfSKV
@DmitryTsepelev
Copy link
Owner

Hey hey, LGTM! Could you please take a look at the rubocop failure?

@smathieu
Copy link
Contributor Author

smathieu commented Feb 7, 2026

@DmitryTsepelev updated

@DmitryTsepelev
Copy link
Owner

One last offence, just break the line into two :)

@smathieu
Copy link
Contributor Author

Sorry I missed that. Should be good now.

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks again!

@DmitryTsepelev DmitryTsepelev merged commit fb72274 into DmitryTsepelev:master Feb 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments