I’m trying to write a conditional upsert with DQL that will only cast a vote on a poll if the poll voting is still open and the user does not already have an existing vote, something like:
upsert {
query {
poll(func: uid(pollUID)) {
pollID as uid
votingOpen as Poll.votingOpen
}
user(func: uid(userUID)) {
User.pollResponses {
PollResponse.poll @filter(uid(pollUID)) {
existingVotes as uid
}
}
}
}
mutation @if(eq(len(existingVotes), 0) AND eq(val(votingOpen), true)) {
set {
# proceed to create new poll vote/response
}
}
}
The check for the length of existing votes works as expected, but the check of whether the poll is open does not. Am I missing something here? My best guess is that votingOpen variable is really an array of booleans and therefore never equates to true, though I can’t think how I could recreate that logic if that is the case.
Any suggestions would be very welcome, I feel like this should be a pretty reasonable thing to want to be able to do.