graphql-compose / graphql-compose/graphql-compose-mongoose

`filter` Arguments cannot be used if `filter` in used in addRelation `prepareArgs`

Open
#292 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
706
Forks
98
PR merge metrics
No merged PRs in 30d

Description

I added a relation as below on `Item`

```
ItemTC.addRelation(
'category',
{
resolver: () => CategoryTC.mongooseResolvers.findOne(),
prepareArgs: {
filter: (source) => ({
_id: source.categoryId,
}),
},
projection: { categoryId: 1 }, // point fields in source object, which should be fetched from DB
}
);
```

When i try to make a query as below

```
query getHotelAndTableMappings($uniqueId: String) {
itemOne {
category(filter: (name:"test")){
name
_id
icon_url
}
name
tags
}

```
It throws an error for `filter` argument.

`filter` can be used if I dont pass the `prepareArg` field while creating a relation. Is this the expected behaviour? Is the a way to fetch _category_ related to _item_ and also apply filters on it?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.