Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApolloError UserInputError - Cannot Delete Custom field #6197

Closed
mnbro opened this issue Jul 10, 2024 · 6 comments
Closed

ApolloError UserInputError - Cannot Delete Custom field #6197

mnbro opened this issue Jul 10, 2024 · 6 comments
Assignees

Comments

@mnbro
Copy link

mnbro commented Jul 10, 2024

Bug Description

I try to delete a custom field but I receive:
ApolloError UserInputError
ApolloError:UserInputError  at new t (/assets/index-JGIdMgsI.js:325:152)  at ? (/assets/index-JGIdMgsI.js:329:75936)  at d (/assets/index-JGIdMgsI.js:324:8526)  at ? (/assets/index-JGIdMgsI.js:324:8441)  at new Promise (<anonymous>)  at Object.then (/assets/index-JGIdMgsI.js:324:8408)  at Object.next (/assets/index-JGIdMgsI.js:324:8536)  at jFe (/assets/index-JGIdMgsI.js:324:1934)  at pW (/assets/index-JGIdMgsI.js:324:2346)  at t.next (/assets/index-JGIdMgsI.js:324:2869)  at ? (/assets/index-JGIdMgsI.js:324:8326)  at Array.forEach (<anonymous>)  at P9 (/assets/index-JGIdMgsI.js:324:8295)  at Object.next (/assets/index-JGIdMgsI.js:324:9289)  at jFe (/assets/index-JGIdMgsI.js:324:1934)  at pW (/assets/index-JGIdMgsI.js:324:2346)  at t.next (/assets/index-JGIdMgsI.js:324:2869)  at Object.next (/assets/index-JGIdMgsI.js:994:23683)  at jFe (/assets/index-JGIdMgsI.js:324:1934)  at pW (/assets/index-JGIdMgsI.js:324:2346)  at t.next (/assets/index-JGIdMgsI.js:324:2869)  at jFe (/assets/index-JGIdMgsI.js:324:1934)  at pW (/assets/index-JGIdMgsI.js:324:2346)  at t.next (/assets/index-JGIdMgsI.js:324:2869)  at Object.onNext [as next] (/assets/index-JGIdMgsI.js:994:24898)  at jFe (/assets/index-JGIdMgsI.js:324:1934)  at pW (/assets/index-JGIdMgsI.js:324:2346)  at t.next (/assets/index-JGIdMgsI.js:324:2869)  at ? (/assets/index-JGIdMgsI.js:994:29354)

Expected behavior

Be able to delete Custom Field

Copy link
Contributor

greptile-apps bot commented Jul 10, 2024

To resolve the ApolloError UserInputError when deleting a custom field, follow these steps:

  1. Check Field Deletion Logic: Ensure the field deletion logic in field-metadata.service.ts is correct and handles custom fields properly.

    public async deleteOneField(
      input: DeleteOneFieldInput,
      workspaceId: string,
    ): Promise<FieldMetadataEntity> {
      // Existing logic
    }
  2. Verify Input Type: Confirm that the DeleteOneFieldInput in delete-field.input.ts is correctly defined.

    @InputType()
    export class DeleteOneFieldInput {
      @IDField(() => UUIDScalarType, {
        description: 'The id of the field to delete.',
      })
      id!: string;
    }
  3. Update Frontend Hook: Ensure the useDeleteOneFieldMetadataItem hook in useDeleteOneFieldMetadataItem.ts is correctly calling the mutation.

    const deleteOneFieldMetadataItem = async (
      idToDelete: DeleteOneFieldMetadataItemMutationVariables['idToDelete'],
    ) => {
      return await mutate({
        variables: {
          idToDelete,
        },
        awaitRefetchQueries: true,
        refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
      });
    };
  4. Exception Handling: Ensure proper exception handling in field-metadata.resolver.ts.

    @Mutation(() => FieldMetadataDTO)
    async deleteOneField(
      @Args('input') input: DeleteOneFieldInput,
      @AuthWorkspace() { id: workspaceId }: Workspace,
    ) {
      // Existing logic
    }

Check these areas to ensure the deletion process is correctly implemented and handles custom fields without errors.

References

/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.resolver.ts
/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts
/packages/twenty-server/src/engine/metadata-modules/field-metadata/dtos/delete-field.input.ts
/packages/twenty-front/src/modules/object-metadata/hooks/useDeleteOneFieldMetadataItem.ts
/packages/twenty-front/src/modules/object-record/hooks/useDeleteOneRecord.ts

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Ask Greptile · Edit Issue Bot Settings

@FelixMalfait
Copy link
Member

Hey, do you have the backend error, if you open the network tab and find the failing graphql query? Thanks!

@mnbro
Copy link
Author

mnbro commented Jul 10, 2024

Hey, do you have the backend error, if you open the network tab and find the failing graphql query? Thanks!

Hi Felix,

Here is what I found in network tab:

`
{"errors":[{"message":"UserInputError","extensions":{"code":"INTERNAL_SERVER_ERROR","response":"Cannot compute composite column name for non-composite field metadata type: LINKS"}}],"data":null}

{"operationName":"DeleteOneFieldMetadataItem","variables":{"idToDelete":"5435a0fb-795c-4c49-bd26-c6ddb9eb11a4"},"query":"mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: {id: $idToDelete}) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n __typename\n }\n}"}`

@FelixMalfait
Copy link
Member

FelixMalfait commented Jul 10, 2024

Related: #4841
@ijreilly how should we move forward? It's actually possible to delete a composite field? Thanks 🙏
Assigning this to you if you don't mind following up

@prateekj117
Copy link
Contributor

@ijreilly I think we can close this issue as this was resolved as part of #6320

@ijreilly
Copy link
Collaborator

Sorry @FelixMalfait and @mnbro I did not see the notifications for this one.
Yes, it can be closed, thanks a lot @prateekj117 !

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Product development ✅ Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants