Use Graphql types in FE and complete mappers removal (#348)
Fix Typescript build issues
This commit is contained in:
@ -1,6 +1,28 @@
|
||||
import { CommentableType, CommentThread } from '~/generated/graphql';
|
||||
import {
|
||||
CommentableType,
|
||||
CommentThread,
|
||||
CommentThreadTarget,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const mockedCommentThreads: Array<CommentThread> = [
|
||||
type MockedCommentThread = Pick<
|
||||
CommentThread,
|
||||
'id' | 'createdAt' | 'updatedAt' | '__typename'
|
||||
> & {
|
||||
commentThreadTargets: Array<
|
||||
Pick<
|
||||
CommentThreadTarget,
|
||||
| 'id'
|
||||
| '__typename'
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
| 'commentableType'
|
||||
| 'commentableId'
|
||||
| 'commentThreadId'
|
||||
> & { commentThread: Pick<CommentThread, 'id' | 'createdAt' | 'updatedAt'> }
|
||||
>;
|
||||
};
|
||||
|
||||
export const mockedCommentThreads: Array<MockedCommentThread> = [
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb230',
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
|
||||
@ -1,6 +1,23 @@
|
||||
import { Company } from '../../generated/graphql';
|
||||
import { Company, User } from '../../generated/graphql';
|
||||
|
||||
export const mockedCompaniesData = [
|
||||
type MockedCompany = Pick<
|
||||
Company,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'domainName'
|
||||
| '__typename'
|
||||
| 'createdAt'
|
||||
| 'address'
|
||||
| 'employees'
|
||||
| '_commentCount'
|
||||
> & {
|
||||
accountOwner: Pick<
|
||||
User,
|
||||
'id' | 'email' | 'displayName' | '__typename'
|
||||
> | null;
|
||||
};
|
||||
|
||||
export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
{
|
||||
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
|
||||
domainName: 'airbnb.com',
|
||||
@ -83,4 +100,4 @@ export const mockedCompaniesData = [
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
] as Array<Company>;
|
||||
];
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import { GraphQLVariables } from 'msw';
|
||||
|
||||
import { Company } from '@/companies/interfaces/company.interface';
|
||||
import { Person } from '@/people/interfaces/person.interface';
|
||||
import { User } from '@/users/interfaces/user.interface';
|
||||
import { BoolExpType } from '@/utils/interfaces/generic.interface';
|
||||
import {
|
||||
CompanyOrderByWithRelationInput,
|
||||
PersonOrderByWithRelationInput,
|
||||
@ -13,7 +9,7 @@ import {
|
||||
|
||||
function filterData<DataT>(
|
||||
data: Array<DataT>,
|
||||
where: BoolExpType<Company> | BoolExpType<Person>,
|
||||
where: Record<string, any>,
|
||||
): Array<DataT> {
|
||||
return data.filter((item) => {
|
||||
// { firstname: {contains: '%string%' }}
|
||||
@ -76,7 +72,7 @@ function filterData<DataT>(
|
||||
|
||||
export function filterAndSortData<DataT>(
|
||||
data: Array<DataT>,
|
||||
where?: BoolExpType<Company> | BoolExpType<Person> | BoolExpType<User>,
|
||||
where?: Record<string, any>,
|
||||
orderBy?: Array<
|
||||
PersonOrderByWithRelationInput &
|
||||
CompanyOrderByWithRelationInput &
|
||||
|
||||
@ -1,6 +1,21 @@
|
||||
import { Person } from '../../modules/people/interfaces/person.interface';
|
||||
import { Company, Person } from '~/generated/graphql';
|
||||
|
||||
export const mockedPeopleData = [
|
||||
type MockedPerson = Pick<
|
||||
Person,
|
||||
| 'id'
|
||||
| 'firstname'
|
||||
| 'lastname'
|
||||
| 'email'
|
||||
| '__typename'
|
||||
| 'phone'
|
||||
| 'city'
|
||||
| '_commentCount'
|
||||
| 'createdAt'
|
||||
> & {
|
||||
company: Pick<Company, 'id' | 'name' | 'domainName' | '__typename'>;
|
||||
};
|
||||
|
||||
export const mockedPeopleData: Array<MockedPerson> = [
|
||||
{
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
__typename: 'Person',
|
||||
@ -73,4 +88,4 @@ export const mockedPeopleData = [
|
||||
|
||||
city: 'Paris',
|
||||
},
|
||||
] satisfies Array<Person>;
|
||||
];
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
import { GraphqlQueryUser } from '@/users/interfaces/user.interface';
|
||||
import { User, Workspace, WorkspaceMember } from '~/generated/graphql';
|
||||
|
||||
export const mockedUsersData: Array<GraphqlQueryUser> = [
|
||||
type MockedUser = Pick<
|
||||
User,
|
||||
'id' | 'email' | 'displayName' | 'avatarUrl' | '__typename'
|
||||
> & {
|
||||
workspaceMember: Pick<WorkspaceMember, 'id' | '__typename'> & {
|
||||
workspace: Pick<
|
||||
Workspace,
|
||||
'id' | 'displayName' | 'domainName' | 'logo' | '__typename'
|
||||
>;
|
||||
};
|
||||
};
|
||||
|
||||
export const mockedUsersData: Array<MockedUser> = [
|
||||
{
|
||||
id: '374fe3a5-df1e-4119-afe0-2a62a2ba481e',
|
||||
__typename: 'User',
|
||||
@ -37,4 +49,4 @@ export const mockedUsersData: Array<GraphqlQueryUser> = [
|
||||
},
|
||||
},
|
||||
},
|
||||
] as GraphqlQueryUser[];
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user