Skip to content

Commit

Permalink
feat: update getProgramsByUser
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Feb 6, 2024
1 parent 71df371 commit f8eb59c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 8 additions & 6 deletions packages/data-layer/src/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import {
SearchResult,
} from "./openapi-search-client/index";
import {
getProgramsByUser,
getProjectById,
getProjects,
getProjectsAndRolesByAddress,
getV1ProjectsByUser,
getV2ProjectsByUser,
} from "./queries";

/**
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 4 additions & 5 deletions packages/data-layer/src/queries.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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: {
Expand Down

0 comments on commit f8eb59c

Please sign in to comment.