ConrabOpto / mst-query

Query library for mobx-state-tree
MIT License
110 stars 7 forks source link

Unable to apply to model after useQuery #18

Closed benjaminkwokhuen closed 2 years ago

benjaminkwokhuen commented 2 years ago

https://codesandbox.io/s/mst-query-basic-example-forked-e6f17?file=/src/index.tsx

After fetching the data, useQuery is not able to apply to mst.


Error: [mobx-state-tree] Error while converting `{"tag":"Limited","content":"10000000"}` to `map<string, AnonymousModel>`:

    at path "/tag" value `"Limited"` is not assignable to type: `AnonymousModel` (Value is not a plain object).
    at path "/content" value `"10000000"` is not assignable to type: `AnonymousModel` (Value is not a plain object).
k-ode commented 2 years ago

Do note that you only need to put the edges of your domain into createRootStore, i.e. the models with an identifier.

So you can either fake an id property, or just keep them local to the query.