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

Generate primitive selectors #25

Closed Kashuab closed 1 year ago

Kashuab commented 1 year ago

One thing that I loved about mst-gql was that it generated selectors for primitive fields on each model.

For example, instead of this:

data => data.token.user(user => user.email.firstName.lastName.createdAt.updatedAt)

I'd like to do this instead:

data => data.token.user(userModelPrimitives)

KashubaK commented 1 year ago

Opted for adding a primitives key to the selector proxy. This is a better approach as developers won't need to import anything to accomplish this.

selectFromUserBaseModel(user => user.primitives.posts(post => post.primitives));

primitives also has some auto-generated documentation that tells you what you'll get:

image