keyFields property Null safety

Map<String, dynamic>? keyFields
read / write

Allows defining the primary key fields for this type.

Pass a true value for any fields you wish to use as key fields. You can also use child fields.

final bookTypePolicy = TypePolicy(
  keyFields: {
    'title': true,
    'author': {
      'name': true,
    }
  },
);

If you don't wish to normalize this type, simply pass an empty Map. In that case, we won't normalize this type and it will be reachable from its parent.

Implementation

Map<String, dynamic>? keyFields;