mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Implemented an option to filter m2a fields using graphql. (#15162)
Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -1077,10 +1077,12 @@ export class GraphQLService {
|
||||
});
|
||||
}
|
||||
} else if (relation.meta?.one_allowed_collections) {
|
||||
/**
|
||||
* @TODO
|
||||
* Looking to add nested typed filters per union type? This is where that's supposed to go.
|
||||
*/
|
||||
ReadableCollectionFilterTypes[relation.collection]?.removeField('item');
|
||||
for (const collection of relation.meta.one_allowed_collections) {
|
||||
ReadableCollectionFilterTypes[relation.collection]?.addFields({
|
||||
[`item__${collection}`]: ReadableCollectionFilterTypes[collection],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ function parseFilterEntry(
|
||||
return { [key]: toArray(value).flatMap((value) => parseFilterValue(value, accountability, context)) } as Filter;
|
||||
} else if (String(key).startsWith('_')) {
|
||||
return { [key]: parseFilterValue(value, accountability, context) };
|
||||
} else if (String(key).startsWith('item__') && isObjectLike(value)) {
|
||||
return { [`item:${String(key).split('item__')[1]}`]: parseFilter(value, accountability, context) } as Filter;
|
||||
} else {
|
||||
return { [key]: parseFilter(value, accountability, context) } as Filter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user