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

Is current injection of GraphQLClient and RootStore okay? #23

Open KashubaK opened 1 year ago

KashubaK commented 1 year ago

The generated rootStore.ts file stores singletons of the RootStore and GraphQLClient, and provides the following functions to access them: getRootStore, getGraphQLClient, setGraphQLClient.

The singletons are not exported themselves. The only way to access them is through those functions. This was done as I believe it would be easier to mock the functions within a test environment as opposed to mocking the singletons.

What are the drawbacks of using this method of injection? What are some convenient ways to improve this (if any?)

Kashuab commented 1 year ago

Update on this, Query and Mutation classes no longer directly depend on the RootStore. Rather, the new DepotGQLClient handles calling RootStore.resolve instead. This is more ideal as there's now only one thing that really depends on it.