diff --git a/src/graphql/helpers.ts b/src/graphql/helpers.ts index 3ed6276c..7afdedcb 100644 --- a/src/graphql/helpers.ts +++ b/src/graphql/helpers.ts @@ -156,7 +156,7 @@ export async function fetchSpaces(args) { const fields = { id: 'string' }; const whereQuery = buildWhereQuery(fields, 's', where); - const queryStr = whereQuery.query; + let queryStr = whereQuery.query; const params: any[] = whereQuery.params; let orderBy = args.orderBy || 'created_at'; @@ -165,6 +165,21 @@ export async function fetchSpaces(args) { orderDirection = orderDirection.toUpperCase(); if (!['ASC', 'DESC'].includes(orderDirection)) orderDirection = 'DESC'; + if (where.strategies_in) { + queryStr += " AND JSON_OVERLAPS(JSON_EXTRACT(settings, '$.strategies[*].name'), JSON_ARRAY(?))"; + params.push(where.strategies_in); + } + + if (where.plugins_in) { + queryStr += " AND JSON_OVERLAPS(JSON_KEYS(settings, '$.plugins') , JSON_ARRAY(?))"; + params.push(where.plugins_in); + } + + if (where.network) { + queryStr += " AND JSON_EXTRACT(settings, '$.network') = ?"; + params.push(where.network); + } + const query = ` SELECT s.* FROM spaces s WHERE s.deleted = 0 ${queryStr} diff --git a/src/graphql/schema.gql b/src/graphql/schema.gql index 73ee28c1..f4c1afb4 100644 --- a/src/graphql/schema.gql +++ b/src/graphql/schema.gql @@ -117,6 +117,9 @@ type Query { input SpaceWhere { id: String id_in: [String] + strategies_in: [String] + plugins_in: [String] + network: String } input RankingWhere {