If anyone is interested, I solved this by making a custom Writer that is almost identical to the original Json writer but utilizes the new getData() method on Models for retrieving data to be written rather than just iterating over the fields. Then anytime you define a proxy on a model/store, if you wish for it to use this writer you just define it in the proxy config. See below.
Defines the custom Writer:
Code:
Ext.define('Ext.data.writer.DeepJson', {
extend:'Ext.data.writer.Json',
getRecordData:function (record, operation) {
var isPhantom = record.phantom === true,
writeAll = this.writeAllFields || isPhantom,
nameProperty = this.nameProperty,
fields = record.fields,
data = {},
changes,
name,
field,
key;
if (writeAll) {
// This is the branch that has been changed from the original Json Writer
data = record.getData(true);
} else {
changes = record.getChanges();
for (key in changes) {
if (changes.hasOwnProperty(key)) {
field = fields.get(key);
name = field[nameProperty] || field.name;
data[name] = changes[key];
}
}
}
if (isPhantom) {
if (operation && operation.records.length > 1) {
data[record.clientIdProperty] = record.internalId;
}
} else {
data[record.idProperty] = record.getId();
}
return data;
}
});
Then we add it to our proxy config:
Code:
proxy:{
type:'rest',
autoAbort:false,
url:'api/graph',
reader:{
type:'json'
},
writer:Ext.create('Ext.data.writer.DeepJson')
}
Doing it this way you still maintain the default behavior of having to persist associations independently, but now have the option of utilizing an entire graph in the event you have something abnormally large where you may not want to submit 100's of requests to the back end.