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

Method names in base models could conflict with GraphQL fields #22

Closed KashubaK closed 1 year ago

KashubaK commented 1 year ago

If someone's type has a field with a name within this list:

We could just prefix them with __, though I'd hate to have to do this.__set('name', 'asdf'); everywhere :\ I'd be fine with prefixing the other keys, though.

Kashuab commented 1 year ago

There were two routes I could've taken with this:

  1. Keep all model data within a data property, and offer a get method to access the data
  2. Prefix auto-generated methods with _ in cases where an object type has fields that conflict with the auto-generated methods

I'm choosing the latter, as I imagine it'd be pretty rare for this to happen. I don't want to add friction just to address the 0.01% of cases where this happens.

class BeepBoopBaseModel {
  @Selectable() set!: string;

  // This function has a `_` prefix since it conflicts with a GraphQL field.
  _set() {
    // ...
  }
}