tectonic
tectonic copied to clipboard
Defaulting model.fields.id to undefined produces error
Example
import { Model } from 'tectonic';
class SomethingModel extends Model {
static modelName = 'something';
static fields = {
description: undefined,
id: undefined,
name: undefined,
};
}
export default SomethingModel;
results in Error: Must supply an ID field for this model
. The docs provide an example with id: undefined
. Is this valid or no?
I had this problem too. Turns out I wasn't passing an id
through to my query (it was misspelled in my component's props). I would expect to receive an ignoring query as it has undefined parameters
error. However, my model, like yours had id: undefined
and so I got Error: Must supply an ID field for this model
instead.
Ideally, if we miss a parameter in our query and have id: undefined
in our model we should get an error saying which parameter is missing. Error: ignoring query as it has the following undefined parameters: 'id'
would be more helpful.
Yep, agreed. I'll see if I can get to this bug this week.
Also, I feel as though this should be valid:
static fields: {
id: undefined
}
which should also be fixed.
Finally, setting static idField
should also fix this error.
Whenever this is completed, you may want to update this documentation as we start off with errors when trying to stand up the examples from docs:
https://tonyhb.github.io/tectonic/api-model.html