From d3b698964ee132e3911c85a6be1869e260e352fb Mon Sep 17 00:00:00 2001 From: eagle Date: Fri, 2 Feb 2024 19:20:58 +0530 Subject: [PATCH] feat: add getProfilesByUser query --- packages/data-layer/src/queries.ts | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/data-layer/src/queries.ts b/packages/data-layer/src/queries.ts index 48c826d69b..e12e3fb925 100644 --- a/packages/data-layer/src/queries.ts +++ b/packages/data-layer/src/queries.ts @@ -1,8 +1,7 @@ import { gql } from "graphql-request"; /** - * Get all the programs that a user is a part of - * @param $alloVersion - The version of Allo + * Get all the programs that a user is a part of in allo v1 * @param $address - The address of the user * @param $chainId - The network ID of the chain * @@ -31,6 +30,37 @@ export const getProgramsByUser = gql` } `; +/** + * Get all the profiles that a user is a part of in allo v2 + * @param $alloVersion - The version of Allo + * @param $address - The address of the user + * @param $chainId - The network ID of the chain + * + * @returns The programs + */ +export const getProfilesByUser = gql` + query ($address: String!, $chainId: Int!) { + projects( + filter: { + tags: { contains: "allo-v2" } + roles: { some: { address: { equalTo: $address } } } + and: { chainId: { equalTo: $chainId } } + } + ) { + id + chainId + metadata + metadataCid + tags + roles { + address + role + createdAtBlock + } + } + } +`; + /** * Get a program by its programId * @param $alloVersion - The version of Allo