Skip to content

Commit

Permalink
Fix Rest API id UUID error (twentyhq#5321)
Browse files Browse the repository at this point in the history
A user has reported an issue with REST API.
We have recently migrated the graphql IDs from UUID to ID type. As Rest
API is leveraging the graphql API under the hood, the Rest API query
builder should be updated accordingly
  • Loading branch information
charlesBochet committed May 7, 2024
1 parent b691894 commit ce4e78a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RecoilRoot } from 'recoil';
import { useUpdateOneRecordMutation } from '@/object-record/hooks/useUpdateOneRecordMutation';

const expectedQueryTemplate = `
mutation UpdateOnePerson($idToUpdate: UUID!, $input: PersonUpdateInput!) {
mutation UpdateOnePerson($idToUpdate: ID!, $input: PersonUpdateInput!) {
updatePerson(id: $idToUpdate, data: $input) {
__typename
xLink {
Expand Down Expand Up @@ -36,13 +36,11 @@ mutation UpdateOnePerson($idToUpdate: UUID!, $input: PersonUpdateInput!) {
describe('useUpdateOneRecordMutation', () => {
it('should return a valid createManyRecordsMutation', () => {
const objectNameSingular = 'person';
const depth = 2;

const { result } = renderHook(
() =>
useUpdateOneRecordMutation({
objectNameSingular,
depth,
}),
{
wrapper: RecoilRoot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class DeleteQueryFactory {
const objectNameSingular = capitalize(objectMetadataItem.nameSingular);

return `
mutation Delete${objectNameSingular}($id: UUID!) {
mutation Delete${objectNameSingular}($id: ID!) {
delete${objectNameSingular}(id: $id) {
id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class UpdateQueryFactory {
return `
mutation Update${capitalize(
objectNameSingular,
)}($id: UUID!, $data: ${capitalize(objectNameSingular)}UpdateInput!) {
)}($id: ID!, $data: ${capitalize(objectNameSingular)}UpdateInput!) {
update${capitalize(objectNameSingular)}(id: $id, data: $data) {
id
${objectMetadata.objectMetadataItem.fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class ApiRestMetadataService {

return `
query FindOne${capitalize(objectNameSingular)}(
$id: UUID!,
$id: ID!,
) {
${objectNameSingular}(id: $id) {
id
Expand Down

0 comments on commit ce4e78a

Please sign in to comment.