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

[REFACTOR] ObjectMetadataItem Scalars #445

Open
prastoin opened this issue Feb 18, 2025 · 1 comment
Open

[REFACTOR] ObjectMetadataItem Scalars #445

prastoin opened this issue Feb 18, 2025 · 1 comment
Assignees
Labels
prio: high type: tech Dependencies upgrade, refactor, typing and so on

Comments

@prastoin
Copy link

prastoin commented Feb 18, 2025

Introduction

This issue results from twentyhq/twenty#10259 (comment)

We had a bug due to a corrupted state that should store an ObjectMetadaItem but seems to get updated to some point to an ObjectMetadataItem.id.

  const { filterableFieldMetadataItems } = useFilterableFieldMetadataItems( // expects objectMetadataItem
    objectMetadataItem?.id, // Type any
)

By digging deeper we can find the follow type declaration:

// packages/twenty-front/src/generated-metadata/graphql.ts
export type Scalars = {
  ID: { input: string; output: string; }
  String: { input: string; output: string; }
  Boolean: { input: boolean; output: boolean; }
  Int: { input: number; output: number; }
  Float: { input: number; output: number; }
  /** Cursor for paging through collections */
  ConnectionCursor: { input: any; output: any; }
  /** A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format. */
  DateTime: { input: any; output: any; }
  /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
  JSON: { input: any; output: any; }
  /** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
  JSONObject: { input: any; output: any; }
  /** A UUID scalar type */
  UUID: { input: unknown; output: unknown; }
  /** The `Upload` scalar type represents a file upload. */
  Upload: { input: any; output: any; }
};

Which will make any of the generated types id JSON and so on typed as any by default.

Fixing this

By mutating the UUID occurence from any to string creates 413 typescript errors.
This should be addressed asap because it will keep increasing

@prastoin prastoin added the type: tech Dependencies upgrade, refactor, typing and so on label Feb 18, 2025
@prastoin prastoin self-assigned this Feb 18, 2025
@lucasbordeau
Copy link

Indeed, we should have string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio: high type: tech Dependencies upgrade, refactor, typing and so on
Projects
Status: No status
Development

No branches or pull requests

2 participants