I have extended my graphql schema to add a totals resolver, but I can't seem to extend the filter to filter on this field. I can't figure out what can be wrong as it seems very simple, so maybe it's not supported? I am using Postgraphile with the makeExtendSchemaPlugin, but I believe the question is basic graphql syntax.
return {
typeDefs: gql`
extend type Note {
lines: Int
}
extend type NoteFilter {
lines: IntFilter
}
`,
resolvers: {
Note: {
resolve: async(parent, args, ctx, info) => {
// logic here
return parent['@lines'].data.length;
}
}
}
}
This seems so simple. The count resolver works, and gives me how many lines are in the note, yet I am not able to filter on it. I don't want to put the filter logic in the lines property itself. If I define a new query and give it a NoteFilter, the filter exists but doesn't include my extended property (lines). Anyone know what I'm doing wrong? This is the end goal I would like for a query:
gql`
{
allNotes(filter: {
lines: {
greaterThan: 10
}
}) {
id
lines
line {
content
}
}
}
`
If you are extending an input object type, the correct syntax is:
extend input NoteFilter {
lines: IntFilter
}
In SDL, input object types are denoted as input
, not type
.