apostrophecms / apostrophecms/apostrophe

Update the 'withType' options in 'relationship' fields to allow an array of types

Open
#4,310 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
4.6k
Forks
650
Avg merge
19h 21m
Merged PRs (30d)
23

Description

## Description

Currently, in 'relationship' fields in ApostropheCMS 3, the `withType` options only accepts a single string to specify the relationship type. However, in the previous version, ApostropheCMS 2, this property could accept an array of types, allowing for greater flexibility in managing relationships.

### Example

Currently:

_customField: {
label: 'custom',
type: 'relationship',
withType: 'type1',
builders: {
// Include only the information you need with a projection
project: {
title: 1,
_url: 1
}
}
}

Proposal:

_customField: {
label: 'custom',
type: 'relationship',
**withType: ['type1', 'type2']**,
builders: {
// Include only the information you need with a projection
project: {
title: 1,
_url: 1
}
}
}

### Motivation

This change would allow developers to define more complex relationships between content, simplifying data structure and making ApostropheCMS 3 even more powerful and adaptable to project-specific needs.

Thank you for your attention!

Contributor guide

Open the contributing guide

Research direction

Start by locating ApostropheCMS 3's relationship-field handling and the validation or query path for the withType option. Check how the existing single-string case is tested, then add coverage for an array containing type1 and type2; done means both types are accepted and relationships behave as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.