A library that generates strongly-typed MobX-state-tree models and stores from a GraphQL schema.
mst-gql is a library that generates strongly-typed MobX-state-tree models and a GraphQL client store from a GraphQL schema. It automates the creation of queries, mutations, and subscriptions, providing a seamless integration between GraphQL's type system and MST's reactive state management. The library solves the problem of maintaining separate type definitions and boilerplate code when using GraphQL with client-side state.
Frontend developers using React with GraphQL who want a model-driven, type-safe state management solution. It's particularly suited for teams already using or interested in MobX-state-tree for its reactive capabilities and structured state.
Developers choose mst-gql for its automatic code generation, which reduces boilerplate and ensures type safety across GraphQL, MST, and TypeScript. Its tight integration with MobX-state-tree offers powerful client-side features like local actions, optimistic updates, and normalized caching that are often cumbersome in other GraphQL clients.
Bindings for mobx-state-tree and GraphQL
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates fully typed MobX-state-tree models, queries, and mutations from your GraphQL endpoint, eliminating boilerplate and ensuring consistency across GraphQL, MST, and TypeScript.
Enables local actions, views, and state lifecycles on generated models, allowing rich client-side behavior beyond basic data fetching, as shown in the custom model examples.
Supports optimistic updates with automatic rollback on mutation failure via recorded patches, improving UI responsiveness as detailed in the README.
Implements a normalized store that ensures single source of truth by reusing model instances, with configurable fetch policies similar to Apollo/urql.
Requires running a CLI tool to scaffold models and configuring HTTP/WebSocket clients, adding overhead compared to drop-in GraphQL clients.
Locked into the MobX-state-tree ecosystem; migrating away would require significant code changes, as all state logic is built on MST.
Customizations in generated .base files are lost on re-scaffolding unless using the force option carefully, leading to potential maintenance issues.
mst-gql is an open-source alternative to the following products:
urql is a lightweight GraphQL client for React and other JavaScript frameworks that provides efficient data fetching and caching with a flexible architecture.
Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL.