forked from cerc-io/snowballtools-base
Add GQL mutation for updating project data in general settings tab (#41)
* Use update project gql client method in UI * Handle save project button based on form change * Fix import order --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
committed by
Ashwin Phatak
co-authored by
neeraj
parent
61120ac44a
commit
5310d7c7d0
@@ -1,8 +1,8 @@
|
||||
import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client';
|
||||
|
||||
import { getUser, getOrganizations, getDeployments, getProjectMembers, searchProjects, getEnvironmentVariables } from './queries';
|
||||
import { AddEnvironmentVariableInput, AddEnvironmentVariablesResponse, GetDeploymentsResponse, GetEnvironmentVariablesResponse, GetOrganizationsResponse, GetProjectMembersResponse, SearchProjectsResponse, GetUserResponse, RemoveMemberResponse, UpdateDeploymentToProdResponse } from './types';
|
||||
import { removeMember, addEnvironmentVariables, updateDeploymentToProd } from './mutations';
|
||||
import { getUser, getOrganizations, getDeployments, getProjectMembers, searchProjects, getEnvironmentVariables, getProject } from './queries';
|
||||
import { AddEnvironmentVariableInput, AddEnvironmentVariablesResponse, GetDeploymentsResponse, GetEnvironmentVariablesResponse, GetOrganizationsResponse, GetProjectMembersResponse, SearchProjectsResponse, GetUserResponse, RemoveMemberResponse, UpdateDeploymentToProdResponse, GetProjectResponse, UpdateProjectResponse, UpdateProjectInput } from './types';
|
||||
import { removeMember, addEnvironmentVariables, updateDeploymentToProd, updateProjectMutation } from './mutations';
|
||||
|
||||
export interface GraphQLConfig {
|
||||
gqlEndpoint: string;
|
||||
@@ -39,6 +39,17 @@ export class GQLClient {
|
||||
return data;
|
||||
}
|
||||
|
||||
async getProject (projectId: string) : Promise<GetProjectResponse> {
|
||||
const { data } = await this.client.query({
|
||||
query: getProject,
|
||||
variables: {
|
||||
projectId
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async getOrganizations () : Promise<GetOrganizationsResponse> {
|
||||
const { data } = await this.client.query({
|
||||
query: getOrganizations
|
||||
@@ -124,4 +135,16 @@ export class GQLClient {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async updateProject (projectId: string, updateProject: UpdateProjectInput): Promise<UpdateProjectResponse> {
|
||||
const { data } = await this.client.mutate({
|
||||
mutation: updateProjectMutation,
|
||||
variables: {
|
||||
projectId,
|
||||
updateProject
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,9 @@ mutation ($deploymentId: String!) {
|
||||
updateDeploymentToProd(deploymentId: $deploymentId)
|
||||
}
|
||||
`;
|
||||
|
||||
export const updateProjectMutation = gql`
|
||||
mutation ($projectId: String!, $updateProject: UpdateProjectInput) {
|
||||
updateProject(projectId: $projectId, updateProject: $updateProject)
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -12,6 +12,28 @@ query {
|
||||
}
|
||||
`;
|
||||
|
||||
export const getProject = gql`
|
||||
query ($projectId: String!) {
|
||||
project(projectId: $projectId) {
|
||||
createdAt
|
||||
description
|
||||
id
|
||||
name
|
||||
template
|
||||
updatedAt
|
||||
prodBranch
|
||||
framework
|
||||
repository
|
||||
webhooks
|
||||
owner {
|
||||
id
|
||||
name
|
||||
email
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const getOrganizations = gql`
|
||||
query {
|
||||
organizations {
|
||||
|
||||
@@ -152,6 +152,10 @@ export type GetUserResponse = {
|
||||
user: User
|
||||
}
|
||||
|
||||
export type GetProjectResponse = {
|
||||
project: Project | null
|
||||
}
|
||||
|
||||
export type SearchProjectsResponse = {
|
||||
searchProjects: Project[]
|
||||
}
|
||||
@@ -169,3 +173,12 @@ export type AddEnvironmentVariableInput = {
|
||||
export type UpdateDeploymentToProdResponse = {
|
||||
updateDeploymentToProd: boolean;
|
||||
}
|
||||
|
||||
export type UpdateProjectResponse = {
|
||||
updateProject: boolean;
|
||||
}
|
||||
|
||||
export type UpdateProjectInput = {
|
||||
name: string
|
||||
description: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user