graphql-compose / graphql-compose/graphql-compose-mongoose
Unable to use _operator while filtering a connection
- Dominant language
- TypeScript
- Stars
- 706
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I'm trying to use the _operators feature for filtering, but I can't get it to work:
This is my package.json section:
```
{
"graphql": "^14.0.2",
"graphql-compose": "^9.0.7",
"graphql-compose-connection": "^8.2.1",
"graphql-compose-mongoose": "^9.7.1",
}
```
My query looks like this:
`trendingComplaintConnection:complaintConnection(after:$after, filter: { viewer: "TRENDING", kind: $kind, category: $categoryName, _operators: {user: {exists: true}} }, first: 6, sort:POPULARITY_DESC) {/*...*/}
`
I get the error:
`graphQl error : Field "exists" is not defined by type FilterFindManyComplaintUserOperatorsInput.
`
It is very hard for me to google this issue as the error message is specific to my case, there's no generic message coming from the **graphql-compose-mongoose** lib that I could google. So I've read the [docs](https://github.com/graphql-compose/graphql-compose-mongoose/blob/master/docs/releases/9.0.0.md#add-nested-fields-support-new-operators-regex-exists-for-filter_operators) and can't help further
Here's my connection and findMany resolver definition:
```
const complaintFindMany = ComplaintTC.mongooseResolvers.findMany({
filter: {
// enables operators for fields
operators: {
user:true
},
}
});
const complaintCountResolver = ComplaintTC.mongooseResolvers.count();
let complaintConnection = ComplaintTC.mongooseResolvers.connection({
filter: {
// enables operators for fields
operators: {
user: true
},
},
sort: {
POPULARITY_DESC: {
value: {popularity: -1},
cursorFields: ['popularity'],
beforeCursorQuery: (rawQuery, cursorData, resolveParams) => {
if (!rawQuery.popularity) rawQuery.popularity = {};
rawQuery.popularity.$gt = cursorData.popularity;
},
afterCursorQuery: (rawQuery, cursorData, resolveParams) => {
if (!rawQuery.popularity) rawQuery.popularity = {};
rawQuery.popularity.$lt = cursorData.popularity;
},
},
}
});
```
Finally, my mongoose object has nothing special
```
const ComplaintSchema = new Schema({
entityGroupId: {type: String},
entityId: {type: String},
user: {
type: UserInfoSchema,
required: false,
},
//...
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.