Skip to content

Shift duplicate index name validation to schema definition time - #1148

Merged
myronmarston merged 2 commits into
block:mainfrom
marcdaniels-toast:mdaniels/shift-left-duplicate-index-name-validation
Apr 24, 2026
Merged

Shift duplicate index name validation to schema definition time#1148
myronmarston merged 2 commits into
block:mainfrom
marcdaniels-toast:mdaniels/shift-left-duplicate-index-name-validation

Conversation

@marcdaniels-toast

Copy link
Copy Markdown
Collaborator

With index inheritance on the horizon, the existing query-time check in GraphQL::Schema#indexed_document_types_by_index_definition_name would need to grow more complex to distinguish legitimate shared indexes (via inheritance) from accidental duplicates. Moving the check earlier — to HasIndices#index via State#register_index — keeps that complexity out of the graphql gem entirely and gives schema authors an immediate, clear error at schema definition time.

I pulled this change out from what I thought was going to be the last PR for Issue #1029 because I wanted to make this change first in a clear, dedicated PR. Did I miss something about why this duplicate index validation wasn't already in the schema_definition gem?

With index inheritance on the horizon, the existing query-time check in
`Schema#indexed_document_types_by_index_definition_name` would need to grow
more complex to distinguish legitimate shared indexes (via inheritance) from
accidental duplicates. Moving the check earlier — to `HasIndices#index` via
`State#register_index` — keeps that complexity out of the graphql gem entirely
and gives authors an immediate, clear error at schema definition time.

Generated with Claude Code

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM apart from some missing type signatures. Thanks for catching this!

@myronmarston
myronmarston enabled auto-merge (squash) April 24, 2026 14:02
@myronmarston
myronmarston disabled auto-merge April 24, 2026 14:02
@myronmarston
myronmarston merged commit d80a375 into block:main Apr 24, 2026
19 checks 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.

2 participants