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:
Sammy Teillet
2023-06-05 17:36:14 +02:00
committed by GitHub
parent fe70f30a29
commit 063ef8a4eb
11 changed files with 27 additions and 31 deletions

View File

@ -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 => ({

View File

@ -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[] = [