I'm working on a project where I'm trying to reproduce the react-admin demo https://github.com/marmelab/react-admin/tree/master/examples/demo in a project based on aws amplify.
I am using this library https://github.com/MrHertal/react-admin-amplify to properly establish the connection.
The react-admin demo uses data-generator-retail (https://github.com/marmelab/react-admin/tree/master/examples/data-generator) in conjunction with "fakerest", "ra-data -fakerest "and" fetch-mock "to set the demo data sourc, and show this data structure:
**customers**
id: integer
first_name: string
last_name: string
email: string
address: string
zipcode: string
city: string
avatar: string
birthday: date
first_seen: date
last_seen: date
has_ordered: boolean
latest_purchase
has_newsletter: boolean
groups: array
nb_commands: integer
total_spent: integer
**categories**
id: number
name: string
**products**
id: integer
category_id: integer
reference: string
width: float
height: float
price: float
thumbnail: string
image: string
description: string
stock: integer
**commands**
id: integer
reference: string
date: date
customer_id: integer
basket: [{ product_id: integer, quantity: integer }]
total_ex_taxes: float
delivery_fees: float
tax_rate: float
taxes: float
total: float
status: 'ordered' | 'delivered' | 'canceled'
returned: boolean
**invoices**
id: integer
date: date
command_id: integer
customer_id: integer
total_ex_taxes: float
delivery_fees: float
tax_rate: float
taxes: float
total: float
**reviews**
id: integer
date: date
status: 'pending' | 'accepted' | 'rejected'
command_id: integer
product_id: integer
customer_id: integer
rating: integer
comment: string
Does anyone know the best way to represent said schema in aws amplify's "schema.graphql" file to reproduce exactly the same result?
My apprenticeship attempts led me to this:
type customers
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
first_name: String
last_name: String
email: AWSEmail
address: String
zipcode: String
city: String
avatar: String
birthday: AWSDateTime
first_seen: AWSDateTime
last_seen: AWSDateTime
has_ordered: Boolean
latest_purchase : AWSDateTime
has_newsletter: Boolean
#groups: array #Doubt about which type of data is equivalent
nb_commands: Int
total_spent: Int}
type categories
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
name: String}
type products
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
category_id: Int
reference: String
width: Float
height: Float
price: Float
thumbnail: String
image: String
description: String
stock: Int}
type commands
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
reference: String
AWSDateTime: AWSDateTime
customer_id: Int
#basket: [{ product_id: Int, quantity: Int }] # Doubt about how to represent this field
total_ex_taxes: Float
delivery_fees: Float
tax_rate: Float
taxes: Float
total: Float
status: ["ordered" , "delivered" , "canceled"]
returned: Boolean}
type invoices
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
AWSDateTime: AWSDateTime
command_id: Int
customer_id: Int
total_ex_taxes: Float
delivery_fees: Float
tax_rate: Float
taxes: Float
total: Float}
type reviews
@model
@auth(rules: [
{ allow: groups, groups: ["admin"] }
])
{
id: ID!
AWSDateTime: AWSDateTime
status: ["pending" , "accepted" , "rejected"]
command_id: Int
product_id: Int
customer_id: Int
rating: Int
comment: String}