as per feedback

Signed-off-by: Andrew Johnson <ajohnson@gocardless.com>
This commit is contained in:
Andrew Johnson
2021-04-08 16:37:22 +01:00
parent ebce9fdbee
commit 2842e953f4
5 changed files with 18 additions and 29 deletions
+9 -5
View File
@@ -60,16 +60,20 @@ export type GithubDeployment = {
};
};
type QueryOptions = {
type QueryParams = {
owner: string;
repo: string;
last: number;
};
type QueryOptions = {
locations: string[];
};
export interface GithubDeploymentsApi {
listDeployments(
params: QueryParams,
options: QueryOptions,
location: string[],
): Promise<GithubDeployment[]>;
}
@@ -119,10 +123,10 @@ export class GithubDeploymentsApiClient implements GithubDeploymentsApi {
}
async listDeployments(
params: QueryParams,
options: QueryOptions,
locations: string[],
): Promise<GithubDeployment[]> {
const baseUrl = getBaseUrl(this.scmIntegrationsApi, locations);
const baseUrl = getBaseUrl(this.scmIntegrationsApi, options.locations);
const token = await this.githubAuthApi.getAccessToken(['repo']);
const graphQLWithAuth = graphql.defaults({
@@ -134,7 +138,7 @@ export class GithubDeploymentsApiClient implements GithubDeploymentsApi {
const response: QueryResponse = await graphQLWithAuth(
deploymentsQuery,
options,
params,
);
return response.repository?.deployments?.nodes?.reverse() || [];
}
@@ -45,7 +45,7 @@ const GithubDeploymentsComponent = ({
const [owner, repo] = projectSlug.split('/');
const { loading, value, error, retry: reload } = useAsyncRetry(
async () => await api.listDeployments({ owner, repo, last }, locations),
async () => await api.listDeployments({ owner, repo, last }, { locations }),
);
if (error) {