-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Conversation
There was a problem hiding this 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.
react-admin/examples/demo/src/types.ts
Lines 5 to 73 in ae7c8ef
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; | |
} |
b3eff48
to
73aaf37
Compare
There was a problem hiding this 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.
Sounds good to me. |
df275d4
to
5407725
Compare
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