Skip to content

OXEAN-133 Add nested relation filter opt-in - #1691

Open
GiuseppeXD wants to merge 4 commits into
masterfrom
oxean-133-remove-relation-filter-syntax
Open

OXEAN-133 Add nested relation filter opt-in#1691
GiuseppeXD wants to merge 4 commits into
masterfrom
oxean-133-remove-relation-filter-syntax

Conversation

@GiuseppeXD

@GiuseppeXD GiuseppeXD commented Aug 19, 2026

Copy link
Copy Markdown

Description ✍️

Make nested relation filters opt-in. Graphoid no longer generates relation filter arguments unless the association declares graphoid_nested_filter: true.

Generated to-many relation fields continue to exclude where, preventing selected relation filters from entering Graphoid's processor.

Overview 🔍

class Sheet < ApplicationRecord
  belongs_to :project, graphoid_nested_filter: true
end

The option is consumed before Mongoid validates association options, then retained on the association reflection for Graphoid schema generation.

# Generated because Sheet#project opted in
sheets(where: { project: { id_not: null } }) {
  data { id }
}

# Rejected because Attachment#record has no opt-in
attachments(where: { record: { id_not: null } }) {
  data { id }
}

Unflagged relations, including _some, _none, and _every collection filters, remain absent from generated input types. Selected relation fields retain order, limit, and skip, but do not expose where.

Checks ☑️

  • relation_filter_restrictions_spec.rb: 6 examples, 0 failures
  • Validates an opted-in belongs_to relation filter
  • Validates unflagged to-many filters and selected-relation where are rejected
  • Ruby syntax and git diff --check pass

end
end

Relation.relations_of(model).each do |name, relation|

@GiuseppeXD GiuseppeXD Aug 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Before graphoid added every Mongoid association to the generated filter inputs.

input AttachmentFilter {
  record: RecordFilter
}

input RecordFilter {
  attachments_some: AttachmentFilter
  attachments_none: AttachmentFilter
  attachments_every: AttachmentFilter
}

Now, graphql-ruby rejects these during static schema validation:

attachments(where: { record: { id_not: null } }) {
  data { id }
}
InputObject 'AttachmentFilter' doesn't accept argument 'record'


association_name = self.class.const_get(:ASSOCIATION_NAME)
result = obj.send(association_name)
result = processor.execute(result, where) if where.present?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No longer executes or validates

records {
  data {
    attachments(where: { type: "picture" }) {
      id
    }
  }
}

However, other operations are still viable

records {
  data {
    attachments(limit: 10, skip: 0, order: { id: ASC }) {
      id
    }
  }
}

@niltonvasques niltonvasques left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead remove the feature from graphoid, lets toggle on/off with an attribute.

In postman this feature is useful in specific situations: records { where: { sheet: { key: "...." }} or sheets: { project: { name: "test"

@GiuseppeXD GiuseppeXD changed the title OXEAN-133 Remove generated relation filter syntax OXEAN-133 Add nested relation filter opt-in Aug 20, 2026
@GiuseppeXD GiuseppeXD self-assigned this Aug 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This tells Mongoid to allow the new type of param in the association

@GiuseppeXD
GiuseppeXD force-pushed the oxean-133-remove-relation-filter-syntax branch from f12b20b to 4b3e4e7 Compare August 24, 2026 18:37
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