Relating to #52 (I'm not allowed to reopen that ticket) I post it as new issue.
My Problem is, that new objects can not created over a relation. For me it looks like a wrong behaviour of vue-api-query. When I do
let childValues= {
val: 'test1',
sequence: 'test2'
};
await this.mainRecord
.childRecord(childValues)
.save()
.then(response => {
...
});
(which I think is the right syntax) I get a exception
Uncaught (in promise) TypeError: Converting circular structure to JSON
When I inspect the error, it is thrown in the axios library in the transformRequest method, line 50 (lib/defaults.js) by stringify method.
if (utils.isObject(data)) {
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
return JSON.stringify(data);
}
Inspecting with chrome shows me, the content of data is childRecord {_builder: Builder)
which looks to me its wrong. When I do a call with existing data, i see a json like formatted content. Same when I create directly a mainChild: data contains json.
In my sample on the top I would expect, data contains
{
val: 'test1',
sequence: 'test2'
}
but it isn't so somehow the given data is passed wrong.
My defined models:
MainRecord.js
import Model from '../../../Model'
import ChildRecord from './ChildRecord';
export default class Type extends Model {
primaryKey() {
return 'Id';
}
resource() {
return 'mainRecord'
}
ChildRecord() {
return this.hasMany(TypeValueList)
}
}
ChildRecord.js
import Model from '../../../Model'
export default class Type extends Model {
primaryKey() {
return 'Id';
}
resource() {
return 'childRecord'
}
}