feat: disable atomic operation on nestjs graphql models (#751)
* feat: no atomic * feat: update front not atomic operations * feat: optional fields for person model & use proper gql type * Fix bug display name * Fix bug update user * Fixed bug avatar URL * Fixed display name on people cell * Fix lint * Fixed storybook display name * Fix storybook requests --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -98,12 +98,8 @@ export function CreateProfile() {
|
||||
id: currentUser?.id,
|
||||
},
|
||||
data: {
|
||||
firstName: {
|
||||
set: data.firstName,
|
||||
},
|
||||
lastName: {
|
||||
set: data.lastName,
|
||||
},
|
||||
firstName: data.firstName,
|
||||
lastName: data.lastName,
|
||||
},
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''],
|
||||
|
||||
@ -73,9 +73,7 @@ export function CreateWorkspace() {
|
||||
const result = await updateWorkspace({
|
||||
variables: {
|
||||
data: {
|
||||
displayName: {
|
||||
set: data.name,
|
||||
},
|
||||
displayName: data.name,
|
||||
},
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''],
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { GET_COMPANIES } from '@/companies/queries';
|
||||
import { CompanyTable } from '@/companies/table/components/CompanyTable';
|
||||
@ -12,10 +11,7 @@ import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer'
|
||||
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
|
||||
import { EntityTableActionBar } from '@/ui/table/action-bar/components/EntityTableActionBar';
|
||||
import { TableContext } from '@/ui/table/states/TableContext';
|
||||
import {
|
||||
InsertCompanyMutationVariables,
|
||||
useInsertCompanyMutation,
|
||||
} from '~/generated/graphql';
|
||||
import { useInsertOneCompanyMutation } from '~/generated/graphql';
|
||||
|
||||
import { SEARCH_COMPANY_QUERY } from '../../modules/search/queries/search';
|
||||
|
||||
@ -25,20 +21,17 @@ const StyledTableContainer = styled.div`
|
||||
`;
|
||||
|
||||
export function Companies() {
|
||||
const [insertCompany] = useInsertCompanyMutation();
|
||||
const [insertCompany] = useInsertOneCompanyMutation();
|
||||
|
||||
async function handleAddButtonClick() {
|
||||
const newCompany: InsertCompanyMutationVariables = {
|
||||
id: uuidv4(),
|
||||
name: '',
|
||||
domainName: '',
|
||||
employees: null,
|
||||
address: '',
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
await insertCompany({
|
||||
variables: newCompany,
|
||||
variables: {
|
||||
data: {
|
||||
name: '',
|
||||
domainName: '',
|
||||
address: '',
|
||||
},
|
||||
},
|
||||
refetchQueries: [
|
||||
getOperationName(GET_COMPANIES) ?? '',
|
||||
getOperationName(SEARCH_COMPANY_QUERY) ?? '',
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { GET_PEOPLE } from '@/people/queries';
|
||||
import { PeopleTable } from '@/people/table/components/PeopleTable';
|
||||
@ -12,7 +11,7 @@ import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer'
|
||||
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
|
||||
import { EntityTableActionBar } from '@/ui/table/action-bar/components/EntityTableActionBar';
|
||||
import { TableContext } from '@/ui/table/states/TableContext';
|
||||
import { useInsertPersonMutation } from '~/generated/graphql';
|
||||
import { useInsertOnePersonMutation } from '~/generated/graphql';
|
||||
|
||||
const StyledTableContainer = styled.div`
|
||||
display: flex;
|
||||
@ -20,18 +19,12 @@ const StyledTableContainer = styled.div`
|
||||
`;
|
||||
|
||||
export function People() {
|
||||
const [insertPersonMutation] = useInsertPersonMutation();
|
||||
const [insertOnePerson] = useInsertOnePersonMutation();
|
||||
|
||||
async function handleAddButtonClick() {
|
||||
await insertPersonMutation({
|
||||
await insertOnePerson({
|
||||
variables: {
|
||||
id: uuidv4(),
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
createdAt: new Date().toISOString(),
|
||||
city: '',
|
||||
data: {},
|
||||
},
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@ import type { Meta } from '@storybook/react';
|
||||
import { userEvent, within } from '@storybook/testing-library';
|
||||
import { graphql } from 'msw';
|
||||
|
||||
import { UPDATE_PERSON } from '@/people/queries';
|
||||
import { UPDATE_ONE_PERSON } from '@/people/queries';
|
||||
import { SEARCH_COMPANY_QUERY } from '@/search/queries/search';
|
||||
import { Company } from '~/generated/graphql';
|
||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||
@ -113,7 +113,7 @@ const editRelationMocks = (
|
||||
if (
|
||||
typeof graphqlMock.info.operationName === 'string' &&
|
||||
[
|
||||
getOperationName(UPDATE_PERSON),
|
||||
getOperationName(UPDATE_ONE_PERSON),
|
||||
getOperationName(SEARCH_COMPANY_QUERY),
|
||||
].includes(graphqlMock.info.operationName)
|
||||
) {
|
||||
@ -122,23 +122,26 @@ const editRelationMocks = (
|
||||
return true;
|
||||
}),
|
||||
...[
|
||||
graphql.mutation(getOperationName(UPDATE_PERSON) ?? '', (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
updateOnePerson: {
|
||||
...fetchOneFromData(mockedPeopleData, req.variables.id),
|
||||
...{
|
||||
company: {
|
||||
id: req.variables.companyId,
|
||||
name: updateSelectedCompany.name,
|
||||
domainName: updateSelectedCompany.domainName,
|
||||
__typename: 'Company',
|
||||
graphql.mutation(
|
||||
getOperationName(UPDATE_ONE_PERSON) ?? '',
|
||||
(req, res, ctx) => {
|
||||
return res(
|
||||
ctx.data({
|
||||
updateOnePerson: {
|
||||
...fetchOneFromData(mockedPeopleData, req.variables.where.id),
|
||||
...{
|
||||
company: {
|
||||
id: req.variables.where.id,
|
||||
name: updateSelectedCompany.name,
|
||||
domainName: updateSelectedCompany.domainName,
|
||||
__typename: 'Company',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}),
|
||||
}),
|
||||
);
|
||||
},
|
||||
),
|
||||
graphql.query(
|
||||
getOperationName(SEARCH_COMPANY_QUERY) ?? '',
|
||||
(req, res, ctx) => {
|
||||
|
||||
Reference in New Issue
Block a user