tectonic
tectonic copied to clipboard
PATCH without response body fails with: There is no source definition which resolves the query
Following the example project, I have this:
export default class AccountConfig extends Model {
static modelName = 'accountConfig';
....
updateOpts(values = {}) {
return {
queryType: UPDATE,
model: this.constructor,
modelId: this.id,
body: {
...this.toJS(), // add existing values
...values, // add values after, overwriting any current values
},
params: {
id: this.id,
},
};
}
}
export const routes = [
...
{
meta: {
url: `${url}/:id`,
method: 'PATCH',
headers: {
...headers
},
},
params: ['id'],
queryType: UPDATE,
},
]
in my component
onSave = (values) => {
const opts = this.props.account.updateOpts(values)
this.props.query(opts, (data) => console.log('d', data))
}
When invoked, I get this warning:
There is no source definition which resolves the query Query(Model: accountConfig, Fields: *, Params: {"id":"65"}, Body: {...}, QueryType: UPDATE), ReturnType: )
and nothing happens.
Changing route to specify model
also fails with same warning.
export const routes = [
...
{
meta: {
url: `${url}/:id`,
method: 'PATCH',
headers: {
...headers
},
},
params: ['id'],
queryType: UPDATE,
model: AccountConfig
},
]
Changing route to specify returns
makes the warning go away, but then the call fails, since the API doesn't return the item on success.
export const routes = [
...
{
meta: {
url: `${url}/:id`,
method: 'PATCH',
headers: {
...headers
},
},
params: ['id'],
queryType: UPDATE,
returns: AccountConfig.item()
},
]
A PATCH
need not have a response body so assuming you'll get one seems like a bug. So the question is, how do I make this work?