-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some infra, need to format graphql call
- Loading branch information
1 parent
801ba52
commit 38cd215
Showing
6 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { GraphQLClient } from 'graphql-request'; | ||
Check failure on line 1 in src/graphql/fetchAllSiloDiscoveryRecommendations.ts GitHub Actions / build-and-upload-artifacts
|
||
import { SILO_DISCOVERY_RECOMMENDATIONS } from './gqls'; | ||
import { makeGraphQLRequest } from './makeGraphQLRequest'; | ||
|
||
export interface SiloDiscoveryRecommendation {} | ||
|
||
const PAGE_SIZE = 20; | ||
|
||
/** | ||
* Fetch all silo discovery recommendations in the organization | ||
* | ||
* @param client - GraphQL client | ||
* @returns All silo discovery recommendations in the organization | ||
*/ | ||
export async function fetchAllSiloDiscoveryRecommendations( | ||
client: GraphQLClient, | ||
): Promise<SiloDiscoveryRecommendation[]> { | ||
const siloDiscoveryRecommendations: SiloDiscoveryRecommendation[] = []; | ||
let offset = 0; | ||
|
||
// Whether to continue looping | ||
let shouldContinue = false; | ||
do { | ||
const { | ||
siloDiscoveryRecommendations: { nodes }, | ||
// eslint-disable-next-line no-await-in-loop | ||
} = await makeGraphQLRequest<{ | ||
/** Silo Discovery Recommendations */ | ||
siloDiscoveryRecommendations: { | ||
/** List */ | ||
nodes: SiloDiscoveryRecommendation[]; | ||
}; | ||
}>(client, SILO_DISCOVERY_RECOMMENDATIONS, { | ||
first: PAGE_SIZE, | ||
offset, | ||
}); | ||
siloDiscoveryRecommendations.push(...nodes); | ||
offset += PAGE_SIZE; | ||
shouldContinue = nodes.length === PAGE_SIZE; | ||
} while (shouldContinue); | ||
|
||
return siloDiscoveryRecommendations.sort((a, b) => | ||
a.title.localeCompare(b.title), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { gql } from 'graphql-request'; | ||
|
||
export const SILO_DISCOVERY_RECOMMENDATIONS = gql` | ||
query TranscendCliVendors($first: Int!, $offset: Int!) { | ||
vendors( | ||
first: $first | ||
offset: $offset | ||
useMaster: false | ||
isExportCsv: true | ||
orderBy: [ | ||
{ field: createdAt, direction: ASC } | ||
{ field: title, direction: ASC } | ||
] | ||
) { | ||
nodes { | ||
id | ||
title | ||
description | ||
dataProcessingAgreementLink | ||
contactName | ||
contactEmail | ||
contactPhone | ||
address | ||
headquarterCountry | ||
headquarterSubDivision | ||
websiteUrl | ||
businessEntity { | ||
title | ||
} | ||
teams { | ||
name | ||
} | ||
owners { | ||
} | ||
attributeValues { | ||
attributeKey { | ||
name | ||
} | ||
name | ||
} | ||
} | ||
} | ||
} | ||
`; |