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

Resolve data returned from queries and mutations #10

Closed KashubaK closed 1 year ago

KashubaK commented 1 year ago

The generated Query and Mutation classes are not yet aware of the RootStore. Somehow this needs to be the case, so they can resolve the response data into their respective models.

KashubaK commented 1 year ago

RootStore and GraphQLClient are now injected into each Mutation class. This may not be optimal but I can't think of another optimal solution. I don't want to pollute the RootStore with the responsibility of encapsulating mutations and queries.

This will work for now as there are exported functions to access these "globals", which should be easily mockable but I'm not too sure if that's the best solution. One could also directly mutate the __rootStore and __client properties of a Mutation instance.