Refactor to fetch organization and deployment details in the parent component (#23)

* Refactor to fetch organization details in the parent component

* Fetch and use deployment details for a project

* Remove deployment field from ProjectDetails type

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
prathamesh0
2024-02-01 11:37:57 +05:30
committed by Ashwin Phatak
co-authored by neeraj
parent 62c969d1ff
commit af021d3357
11 changed files with 199 additions and 121 deletions
+12 -1
View File
@@ -1,6 +1,6 @@
import { ApolloClient, InMemoryCache, NormalizedCacheObject } from '@apollo/client';
import { getUser, getOrganizations } from './gql-queries';
import { getUser, getOrganizations, getDeployments } from './gql-queries';
export interface GraphQLConfig {
gqlEndpoint: string;
@@ -31,4 +31,15 @@ export class GQLClient {
return data;
}
async getDeployments (projectId: string) : Promise<any> {
const { data } = await this.client.query({
query: getDeployments,
variables: {
projectId
}
});
return data;
}
}
+28
View File
@@ -15,10 +15,13 @@ query {
export const getOrganizations = gql`
query {
organizations {
id
name
projects {
id
owner {
id
name
}
deployments {
id
@@ -42,3 +45,28 @@ query {
}
}
`;
export const getDeployments = gql`
query ($projectId: String!) {
deployments(projectId: $projectId) {
id
domain{
branch
createdAt
isRedirected
id
name
status
updatedAt
}
branch
commitHash
title
environment
isCurrent
status
createdAt
updatedAt
}
}
`;