Files
twenty/packages/twenty-server/test/integration/graphql/utils/update-one-operation-factory.util.ts
T
Marie 1ad8c05fbc groupBy fix + typeMapper fix (#15433)
groupBy fix: when a group's dimension value is NULL, we need to adapt
the raw sql (stage: NULL -> stage IS NULL)

typeMapper fix: a graphql type should be made non-nullable if was
indicated so + does not have a default value. our check on not having a
default value was limited to having a null defaultValue instead of
having a null or undefined defaultValue. This is a breaking change, but
all the queries that were providing a null value for these args were not
functioning anyway, and luckily in the FE we declared all queries adding
a `!` already.
2025-10-30 10:14:56 +00:00

29 lines
787 B
TypeScript

import gql from 'graphql-tag';
import { capitalize } from 'twenty-shared/utils';
type UpdateOneOperationFactoryParams = {
objectMetadataSingularName: string;
gqlFields: string;
data?: object;
recordId: string;
};
export const updateOneOperationFactory = ({
objectMetadataSingularName,
gqlFields,
data = {},
recordId,
}: UpdateOneOperationFactoryParams) => ({
query: gql`
mutation Update${capitalize(objectMetadataSingularName)}($${objectMetadataSingularName}Id: UUID!, $data: ${capitalize(objectMetadataSingularName)}UpdateInput!) {
update${capitalize(objectMetadataSingularName)}(id: $${objectMetadataSingularName}Id, data: $data) {
${gqlFields}
}
}
`,
variables: {
data,
[`${objectMetadataSingularName}Id`]: recordId,
},
});