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

Add better types to data-generator #9764

Merged
merged 7 commits into from Apr 18, 2024
Merged

Add better types to data-generator #9764

merged 7 commits into from Apr 18, 2024

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Apr 10, 2024

Problem

When using the data-generator-retail package, the generated is not typed, making consumers declare the generated types themselves.

Solution

Provide types

Wait for next version of json-graphql-server or the GQL demo won't work

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind rebasing on next? Also, the e-commerce demo redefines those types, it should now import them instead.

export interface Category extends RaRecord {
name: string;
}
export interface Product extends RaRecord {
category_id: Identifier;
description: string;
height: number;
image: string;
price: number;
reference: string;
stock: number;
thumbnail: string;
width: number;
}
export interface Customer extends RaRecord {
first_name: string;
last_name: string;
address: string;
stateAbbr: string;
city: string;
zipcode: string;
avatar: string;
birthday: string;
first_seen: string;
last_seen: string;
has_ordered: boolean;
latest_purchase: string;
has_newsletter: boolean;
groups: string[];
nb_commands: number;
total_spent: number;
email: string;
}
export type OrderStatus = 'ordered' | 'delivered' | 'cancelled';
export interface Order extends RaRecord {
status: OrderStatus;
basket: BasketItem[];
date: Date;
total: number;
total_ex_taxes: number;
delivery_fees: number;
tax_rate: number;
taxes: number;
customer_id: Identifier;
reference: string;
}
export type BasketItem = {
product_id: Identifier;
quantity: number;
};
export interface Invoice extends RaRecord {
date: Date;
}
export type ReviewStatus = 'accepted' | 'pending' | 'rejected';
export interface Review extends RaRecord {
date: Date;
status: ReviewStatus;
customer_id: Identifier;
product_id: Identifier;
comment: string;
}

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But I'm thinking: since we're targeting v5, maybe we can get rid of the serialized/unserialized date switch? I think it makes more sense to have it always serialized.

@djhi
Copy link
Contributor Author

djhi commented Apr 11, 2024

LGTM. But I'm thinking: since we're targeting v5, maybe we can get rid of the serialized/unserialized date switch? I think it makes more sense to have it always serialized.

Sounds good to me.

examples/demo/package.json Outdated Show resolved Hide resolved
examples/demo/package.json Show resolved Hide resolved
examples/demo/package.json Outdated Show resolved Hide resolved
@fzaninotto fzaninotto merged commit b59afe0 into next Apr 18, 2024
12 checks passed
@fzaninotto fzaninotto deleted the data-generator-types branch April 18, 2024 16:48
@fzaninotto fzaninotto added this to the 5.0.0 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review v5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants