Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint: Unnecessary @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) on "X to one" edge #347

Open
obi1kenobi opened this issue Jul 7, 2023 · 0 comments
Labels
A-syntax Area: query or schema syntax C-feature-request Category: request for new future functionality E-medium Call for participation: experience needed to fix: medium / intermediate

Comments

@obi1kenobi
Copy link
Owner

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.
@obi1kenobi obi1kenobi added A-syntax Area: query or schema syntax C-feature-request Category: request for new future functionality E-medium Call for participation: experience needed to fix: medium / intermediate labels Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntax Area: query or schema syntax C-feature-request Category: request for new future functionality E-medium Call for participation: experience needed to fix: medium / intermediate
Projects
None yet
Development

No branches or pull requests

1 participant