Field.fromJson constructor

Field.fromJson(
  1. Map json
)

Implementation

factory Field.fromJson(Map json) {
  return Field(
    kind: switch (json['kind']) {
      'scalar' => FieldKind.scalar,
      'object' => FieldKind.object,
      'enum' => FieldKind.$enum,
      _ => FieldKind.unsupported,
    },
    name: json['name'],
    isRequired: switch (json['isRequired']) {
      bool value => value,
      _ => false,
    },
    isList: switch (json['isList']) {
      bool value => value,
      _ => false,
    },
    isUnique: switch (json['isUnique']) {
      bool value => value,
      _ => false,
    },
    isId: switch (json['isId']) {
      bool value => value,
      _ => false,
    },
    isReadOnly: switch (json['isReadOnly']) {
      bool value => value,
      _ => false,
    },
    isGenerated: switch (json['isGenerated']) {
      bool value => value,
      _ => false,
    },
    isUpdatedAt: switch (json['isUpdatedAt']) {
      bool value => value,
      _ => false,
    },
    type: json['type'],
    dbName: json['dbName'],
    hasDefaultValue: switch (json['hasDefaultValue']) {
      bool value => value,
      _ => false,
    },
    $default: json['default'],
    relationFromFields: json['relationFromFields'] == null
        ? null
        : (json['relationFromFields'] as Iterable).cast(),
    relationToFields: json['relationToFields'] == null
        ? null
        : (json['relationToFields'] as Iterable).cast(),
    relationOnDelete: json['relationOnDelete'],
    relationName: json['relationName'],
    documentation: json['documentation'],
  );
}