prisma / prisma-admin-feedback

Feedback for Prisma Admin (currently in invite-only preview)
6 stars 1 forks source link

Data for custom components #88

Open kuldar opened 5 years ago

kuldar commented 5 years ago

While trying to build a custom component for Prisma Admin, it became apparent that it's difficult to handle the data without any field/type level meta information.

Currently it's only possible to use a field names to refer to data, which ties custom views only to specific types and makes them very brittle to changes in the datamodel.

This means we should provide some additional information on the types and/or fields, which would help to build more generic components that render Text fields, Enum fields etc in a specific way, regardless of the field name.

An initial proposal by @Huvik is to add an additional url param (/url?data=JSON.stringify(data)&fields=JSON.stringify(fields)) with the following field level info:

export interface Field {
  isList: boolean
  isRequired: boolean
  isRelation: boolean
  typeName: string
  typeString: string
  name: string
  width: number
  children?: Dictionary<Field>
}

This would be a great moment to discuss what additional information would be needed to build flexible custom UI components for data of any shape.