mirror of
https://github.com/lingble/twenty.git
synced 2025-11-01 13:17:57 +00:00
Sammy/t refactor services use generated code (#194)
* refactor: use generated queries for Companies * refactor: remove useQuery from service, use generated code * refactor: rename to ts file instead of tsx * bugfix: use generatd queries, and fix non existing id in workspace member query
This commit is contained in:
@@ -1219,7 +1219,7 @@ export type GetCurrentUserQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
|
||||
export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', id: string, workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
|
||||
|
||||
export type GetUsersQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
@@ -1867,6 +1867,7 @@ export const GetCurrentUserDocument = gql`
|
||||
email
|
||||
displayName
|
||||
workspaceMember {
|
||||
id
|
||||
workspace {
|
||||
id
|
||||
domainName
|
||||
|
||||
@@ -33,7 +33,7 @@ export type GraphqlQueryCompany = {
|
||||
|
||||
accountOwner?: GraphqlQueryUser | null;
|
||||
pipes?: GraphqlQueryPipeline[] | null;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationCompany = {
|
||||
@@ -46,7 +46,7 @@ export type GraphqlMutationCompany = {
|
||||
createdAt?: string;
|
||||
|
||||
accountOwnerId?: string;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export const mapToCompany = (company: GraphqlQueryCompany): Company => ({
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { gql, QueryResult, useQuery } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { SelectedSortType } from '@/filters-and-sorts/interfaces/sorts/interface';
|
||||
import {
|
||||
CompanyOrderByWithRelationInput as Companies_Order_By,
|
||||
CompanyWhereInput as Companies_Bool_Exp,
|
||||
SortOrder as Order_By,
|
||||
useGetCompaniesQuery,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { GraphqlQueryCompany } from '../interfaces/company.interface';
|
||||
|
||||
export type CompaniesSelectedSortType = SelectedSortType<Companies_Order_By>;
|
||||
|
||||
export const GET_COMPANIES = gql`
|
||||
@@ -35,10 +34,8 @@ export const GET_COMPANIES = gql`
|
||||
export function useCompaniesQuery(
|
||||
orderBy: Companies_Order_By[],
|
||||
where: Companies_Bool_Exp,
|
||||
): QueryResult<{ companies: GraphqlQueryCompany[] }> {
|
||||
return useQuery<{ companies: GraphqlQueryCompany[] }>(GET_COMPANIES, {
|
||||
variables: { orderBy, where },
|
||||
});
|
||||
) {
|
||||
return useGetCompaniesQuery({ variables: { orderBy, where } });
|
||||
}
|
||||
|
||||
export const defaultOrderBy: Companies_Order_By[] = [
|
||||
|
||||
@@ -33,7 +33,7 @@ export type GraphqlQueryPerson = {
|
||||
|
||||
company?: GraphqlQueryCompany | null;
|
||||
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationPerson = {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { gql, QueryResult, useQuery } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { SelectedSortType } from '@/filters-and-sorts/interfaces/sorts/interface';
|
||||
import {
|
||||
PersonOrderByWithRelationInput as People_Order_By,
|
||||
PersonWhereInput as People_Bool_Exp,
|
||||
SortOrder,
|
||||
useGetPeopleQuery,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { GraphqlQueryPerson } from '../interfaces/person.interface';
|
||||
|
||||
export type PeopleSelectedSortType = SelectedSortType<People_Order_By>;
|
||||
|
||||
export const GET_PEOPLE = gql`
|
||||
@@ -37,8 +36,8 @@ export const GET_PEOPLE = gql`
|
||||
export function usePeopleQuery(
|
||||
orderBy: People_Order_By[],
|
||||
where: People_Bool_Exp,
|
||||
): QueryResult<{ people: GraphqlQueryPerson[] }> {
|
||||
return useQuery<{ people: GraphqlQueryPerson[] }>(GET_PEOPLE, {
|
||||
) {
|
||||
return useGetPeopleQuery({
|
||||
variables: { orderBy, where },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ export interface GraphqlQueryPipeline {
|
||||
id: string;
|
||||
name?: string;
|
||||
icon?: string | null;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ export interface User {
|
||||
id: string;
|
||||
email?: string;
|
||||
displayName?: string;
|
||||
workspaceMember?: WorkspaceMember;
|
||||
workspaceMember?: WorkspaceMember | null;
|
||||
}
|
||||
|
||||
export type GraphqlQueryUser = {
|
||||
id: string;
|
||||
email?: string;
|
||||
displayName?: string;
|
||||
workspaceMember?: GraphqlQueryWorkspaceMember;
|
||||
__typename: string;
|
||||
workspaceMember?: GraphqlQueryWorkspaceMember | null;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationUser = {
|
||||
@@ -25,7 +25,7 @@ export type GraphqlMutationUser = {
|
||||
email?: string;
|
||||
displayName?: string;
|
||||
workspaceMemberId?: string;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export const mapToUser = (user: GraphqlQueryUser): User => ({
|
||||
|
||||
@@ -12,13 +12,13 @@ export interface WorkspaceMember {
|
||||
export type GraphqlQueryWorkspaceMember = {
|
||||
id: string;
|
||||
workspace: GraphqlQueryWorkspace;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationWorkspaceMember = {
|
||||
id: string;
|
||||
workspace_id: string;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export const mapToWorkspaceMember = (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { gql, QueryResult, useQuery } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { GraphqlQueryUser } from '../interfaces/user.interface';
|
||||
import { useGetCurrentUserQuery as generatedUseGetCurrentUserQuery } from '~/generated/graphql';
|
||||
|
||||
export const GET_CURRENT_USER = gql`
|
||||
query GetCurrentUser($uuid: String) {
|
||||
@@ -9,6 +9,7 @@ export const GET_CURRENT_USER = gql`
|
||||
email
|
||||
displayName
|
||||
workspaceMember {
|
||||
id
|
||||
workspace {
|
||||
id
|
||||
domainName
|
||||
@@ -20,10 +21,8 @@ export const GET_CURRENT_USER = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export function useGetCurrentUserQuery(userId: string | null): QueryResult<{
|
||||
users: GraphqlQueryUser[];
|
||||
}> {
|
||||
return useQuery<{ users: GraphqlQueryUser[] }>(GET_CURRENT_USER, {
|
||||
export function useGetCurrentUserQuery(userId: string | null) {
|
||||
return generatedUseGetCurrentUserQuery({
|
||||
variables: {
|
||||
uuid: userId,
|
||||
},
|
||||
@@ -10,7 +10,7 @@ export type GraphqlQueryWorkspace = {
|
||||
displayName?: string;
|
||||
domainName?: string;
|
||||
logo?: string | null;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationWorkspace = {
|
||||
@@ -18,7 +18,7 @@ export type GraphqlMutationWorkspace = {
|
||||
displayName?: string;
|
||||
domainName?: string;
|
||||
logo?: string | null;
|
||||
__typename: string;
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
export const mapToWorkspace = (
|
||||
|
||||
Reference in New Issue
Block a user