diff --git a/packages/data-layer/src/data-layer.ts b/packages/data-layer/src/data-layer.ts index 82536468ec..dad8584b67 100644 --- a/packages/data-layer/src/data-layer.ts +++ b/packages/data-layer/src/data-layer.ts @@ -24,10 +24,11 @@ import { SearchResult, } from "./openapi-search-client/index"; import { - getProgramsByUser, getProjectById, getProjects, getProjectsAndRolesByAddress, + getV1ProjectsByUser, + getV2ProjectsByUser, } from "./queries"; /** @@ -141,11 +142,12 @@ export class DataLayer { chainId, }; - const response: { projects: Program[] } = await request( - this.gsIndexerEndpoint, - getProgramsByUser, - requestVariables, - ); + let response: { projects: Program[] } = { projects: [] }; + + const query = + alloVersion === "allo-v1" ? getV1ProjectsByUser : getV2ProjectsByUser; + + response = await request(this.gsIndexerEndpoint, query, requestVariables); const programs = response.projects; diff --git a/packages/data-layer/src/queries.ts b/packages/data-layer/src/queries.ts index e12e3fb925..f1af905d89 100644 --- a/packages/data-layer/src/queries.ts +++ b/packages/data-layer/src/queries.ts @@ -1,13 +1,13 @@ import { gql } from "graphql-request"; /** - * Get all the programs that a user is a part of in allo v1 + * Manager: 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 * * @returns The programs */ -export const getProgramsByUser = gql` +export const getV1ProjectsByUser = gql` query ($address: String!, $chainId: Int!) { projects( filter: { @@ -31,14 +31,13 @@ export const getProgramsByUser = gql` `; /** - * Get all the profiles that a user is a part of in allo v2 - * @param $alloVersion - The version of Allo + * Manager: Get all the projects that a user is a part of in allo v2 * @param $address - The address of the user * @param $chainId - The network ID of the chain * * @returns The programs */ -export const getProfilesByUser = gql` +export const getV2ProjectsByUser = gql` query ($address: String!, $chainId: Int!) { projects( filter: {