trustfall
trustfall copied to clipboard
Lint: Unnecessary `@fold @transform(op: "count") @filter(op: ">", value: ["$zero"])` on "X to one" edge
Consider this schema:
type Post {
content: String!
author: User # or optionally `User!` -- same in both cases
}
type User {
name: String!
}
and this query:
{
Post {
content @output
author @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) {
name @filter(op: "=", value: ["$author"])
}
}
}
The @fold @transform(op: "count") @filter(op: ">", value: ["$zero"])
part can be removed without changing the query semantics at all, since:
- The
author
edge returns a maximum of one neighboring vertex. - If there is no
author
, the result would be discarded both with and without the fold. - Nothing is output from the fold, so none of the output types change.