forked from cerc-io/snowballtools-base
Add GQL query for projects search in app (#38)
* Find projects based on search text * Use get search projects client method in UI * Fetch searched projects inside useCombobox hook * Get searched project from project entity * Remove non required search projects filtering * Fetch projects if user is owner or project member --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
committed by
Ashwin Phatak
co-authored by
neeraj
parent
cbc394f9f8
commit
c2b997a17b
@@ -1 +1,2 @@
|
||||
export * from './src/client';
|
||||
export * from './src/types';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client';
|
||||
|
||||
import { getUser, getOrganizations, getDeployments, getProjectMembers } from './queries';
|
||||
import { GetDeploymentsResponse, GetOrganizationsResponse, GetProjectMembersResponse, GetUserResponse, RemoveMemberResponse } from './types';
|
||||
import { getUser, getOrganizations, getDeployments, getProjectMembers, searchProjects } from './queries';
|
||||
import { GetDeploymentsResponse, GetOrganizationsResponse, GetProjectMembersResponse, SearchProjectsResponse, GetUserResponse, RemoveMemberResponse } from './types';
|
||||
import { removeMember } from './mutations';
|
||||
|
||||
export interface GraphQLConfig {
|
||||
@@ -79,4 +79,15 @@ export class GQLClient {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async searchProjects (searchText: string) : Promise<SearchProjectsResponse> {
|
||||
const { data } = await this.client.query({
|
||||
query: searchProjects,
|
||||
variables: {
|
||||
searchText
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +97,28 @@ query ($projectId: String!) {
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const searchProjects = gql`
|
||||
query ($searchText: String!) {
|
||||
searchProjects(searchText: $searchText) {
|
||||
id
|
||||
name
|
||||
prodBranch
|
||||
repository
|
||||
createdAt
|
||||
description
|
||||
framework
|
||||
prodBranch
|
||||
webhooks
|
||||
updatedAt
|
||||
template
|
||||
repository
|
||||
organization {
|
||||
id
|
||||
name
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -84,7 +84,7 @@ export type ProjectMember = {
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type Project = {
|
||||
export type OrganizationProject = {
|
||||
id: string
|
||||
owner: User
|
||||
deployments: Deployment[]
|
||||
@@ -104,12 +104,30 @@ export type Project = {
|
||||
export type Organization = {
|
||||
id: string
|
||||
name: string
|
||||
projects: Project[]
|
||||
projects: OrganizationProject[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
members: OrganizationMember[]
|
||||
}
|
||||
|
||||
export type Project = {
|
||||
id: string
|
||||
owner: User
|
||||
deployments: Deployment[]
|
||||
name: string
|
||||
repository: string
|
||||
prodBranch: string
|
||||
description: string
|
||||
template: string
|
||||
framework: string
|
||||
webhooks: string[]
|
||||
members: ProjectMember[]
|
||||
environmentVariables: EnvironmentVariable[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
organization: Organization
|
||||
}
|
||||
|
||||
export type GetProjectMembersResponse = {
|
||||
projectMembers: ProjectMember[]
|
||||
}
|
||||
@@ -129,3 +147,7 @@ export type GetOrganizationsResponse = {
|
||||
export type GetUserResponse = {
|
||||
user: User
|
||||
}
|
||||
|
||||
export type SearchProjectsResponse = {
|
||||
searchProjects: Project[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user