Kashuab / mobx-depot

Scaffold MobX-powered models, queries and mutations with your GraphQL schema.
https://mobx-depot.dev
MIT License
8 stars 0 forks source link

Reduce verbosity in base models #16

Closed Kashuab closed 1 year ago

Kashuab commented 1 year ago

Every property in a base model class gets these definitions:

  private _firstName?: string;
  get firstName(): string {
    if (this._firstName === undefined) throw new Error('Property firstName is not selected');
    return this._firstName;
  }
  set firstName(value: string) {
    this._firstName = value;
  }

I wonder if there's a better way do handle this that would be less verbose. Models with a ton of properties would seem pretty messy, but luckily developers won't be touching the base model.

KashubaK commented 1 year ago

Defer error throwing to Selectable decorator. Field declarations now look like:

@Selectable() attackerCharacterIds!: string[];