diff --git a/src/graphql/operations/votes.ts b/src/graphql/operations/votes.ts index b8f3ffba..b259df20 100644 --- a/src/graphql/operations/votes.ts +++ b/src/graphql/operations/votes.ts @@ -24,7 +24,7 @@ async function query(parent, args, context?, info?) { vp_state: 'string' }; const whereQuery = buildWhereQuery(fields, 'v', where); - const queryStr = whereQuery.query; + let queryStr = whereQuery.query; const params: any[] = whereQuery.params; let orderBy = args.orderBy || 'created'; @@ -36,6 +36,12 @@ async function query(parent, args, context?, info?) { let votes: any[] = []; + if (where.choice_in) { + queryStr += + ' AND JSON_OVERLAPS(JSON_KEYS(choice), JSON_ARRAY(?)) OR JSON_OVERLAPS(choice, JSON_ARRAY(?)) OR choice = ?'; + params.push(where.choice_in, where.choice_in, where.choice_in); + } + const query = ` SELECT v.* FROM votes v WHERE 1 = 1 ${queryStr} diff --git a/src/graphql/schema.gql b/src/graphql/schema.gql index 73ee28c1..67a9e2e9 100644 --- a/src/graphql/schema.gql +++ b/src/graphql/schema.gql @@ -248,6 +248,7 @@ input VoteWhere { vp_lte: Float vp_state: String vp_state_in: [String] + choice_in: [String] } input AliasWhere {