Skip to content

GraphQL: add _parent filter to query types #89

Description

@mitselek

Problem

There is no way to query "all Members whose parent is Organization X" via GraphQL. The filter types are generated only from user-defined property definitions (schema.js:296-301), so system properties like _parent are excluded.

Every parent-child query must fall back to the REST API.

Suggested change

schema.js (~line 296):

const filterFields = ['  _id: ID', '  _search: String', '  _parent: IDFilter']

filters.js, buildMongoFilter() (~line 28):

// Handle _parent filter (system property, not in propDefs)
if (key === '_parent') {
  if (typeof value === 'string') {
    filter['private._parent.reference'] = getObjectId(value)
  } else if (typeof value === 'object' && value.eq) {
    filter['private._parent.reference'] = getObjectId(value.eq)
  }
  continue
}

Example query this enables

query {
  member(filter: { _parent: { eq: "org-id-here" } }) {
    _id
    name { string }
  }
}

Use case

Polyphony PoC: listing all members of a choir (Organization → Member parent-child relationship). This is the highest-traffic query in the app.

~13 lines changed, purely additive.

Split from #88

(ER:Codd + Saavedra)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions