How to use the mst-gql.configureStoreMixin function in mst-gql

To help you get started, we’ve selected a few mst-gql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mobxjs / mst-gql / tests / lib / todos / models / RootStore.base.js View on Github external
/* This is a mst-gql generated file, don't modify it manually */
/* eslint-disable */
import { types } from "mobx-state-tree"
import { MSTGQLStore, configureStoreMixin } from "mst-gql"

import { TodoModel } from "./TodoModel"
import { todoModelPrimitives, TodoModelSelector } from "./TodoModel.base"


/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Todo', () => TodoModel]], ['Todo']))
  .props({
    todos: types.optional(types.map(types.late(() => TodoModel)), {})
  })
  .actions(self => ({
    queryTodos(variables, resultSelector = todoModelPrimitives.toString(), options = {}) {
      return self.query(`query todos { todos {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    mutateToggleTodo(variables, resultSelector = todoModelPrimitives.toString(), optimisticUpdate) {
      return self.mutate(`mutation toggleTodo($id: ID!) { toggleTodo(id: $id) {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, optimisticUpdate)
    },
  }))
github mobxjs / mst-gql / examples / 3-using-subscriptions / src / app / models / RootStore.ts View on Github external
/* This is a mst-sql generated file */
import { localStorageMixin } from "mst-gql"

/* #region type-imports */
import { types } from "mobx-state-tree"
import { MSTGQLStore, configureStoreMixin, QueryOptions } from "mst-gql"
import { Message, messagePrimitives } from "./index"
/* #endregion */

/* #region type-def */
/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStore = MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Message', () => Message]], ['Message']))
  .props({
    messages: types.optional(types.map(types.late(() => Message)), {})
  })
  .actions(self => ({
    queryMessages(variables?: {  }, resultSelector = messagePrimitives, options: QueryOptions = {}) {
      return self.query(`query messages { messages {
        ${resultSelector}
      } }`, variables, options)
    },
    subscribeNewMessages(variables?: {  }, resultSelector = messagePrimitives) {
      return self.subscribe(`subscription newMessages { newMessages {
        ${resultSelector}
      } }`, variables)
    },    
  }))
 /* #endregion */
github mobxjs / mst-gql / examples / 2-scaffolding / src / models / RootStore.base.ts View on Github external
import { PokemonEvolutionRequirementModel, PokemonEvolutionRequirementModelType } from "./PokemonEvolutionRequirementModel"
import { pokemonEvolutionRequirementModelPrimitives, PokemonEvolutionRequirementModelSelector } from "./PokemonEvolutionRequirementModel.base"


/* The TypeScript type that explicits the refs to other models in order to prevent a circular refs issue */
type Refs = {
  pokemons: ObservableMap,
  attacks: ObservableMap
}

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = withTypedRefs()(MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Pokemon', () => PokemonModel], ['PokemonDimension', () => PokemonDimensionModel], ['PokemonAttack', () => PokemonAttackModel], ['Attack', () => AttackModel], ['PokemonEvolutionRequirement', () => PokemonEvolutionRequirementModel]], ['Pokemon', 'Attack']))
  .props({
    pokemons: types.optional(types.map(types.late((): any => PokemonModel)), {}),
    attacks: types.optional(types.map(types.late((): any => AttackModel)), {})
  })
  .actions(self => ({
    queryPokemons(variables: { first: number }, resultSelector: string | ((qb: PokemonModelSelector) => PokemonModelSelector) = pokemonModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ pokemons: PokemonModelType[]}>(`query pokemons($first: Int!) { pokemons(first: $first) {
        ${typeof resultSelector === "function" ? resultSelector(new PokemonModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryPokemon(variables: { id?: string, name?: string }, resultSelector: string | ((qb: PokemonModelSelector) => PokemonModelSelector) = pokemonModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ pokemon: PokemonModelType}>(`query pokemon($id: String, $name: String) { pokemon(id: $id, name: $name) {
        ${typeof resultSelector === "function" ? resultSelector(new PokemonModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
  })))
github mobxjs / mst-gql / examples / 5-todos / src / models / RootStore.js View on Github external
/* This is a mst-sql generated file */

/* #region type-imports */
import { types } from "mobx-state-tree"
import { MSTGQLStore, configureStoreMixin } from "mst-gql"
import { Todo, todoPrimitives } from "./index"
/* #endregion */

/* #region type-def */
/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStore = MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Todo', () => Todo]], ['Todo']))
  .props({
    todos: types.optional(types.map(types.late(() => Todo)), {})
  })
  .actions(self => ({
    queryAllTodoes(variables, resultSelector = todoPrimitives, options = {}) {
      return self.query(`query allTodoes($filter: TodoFilter, $orderBy: TodoOrderBy, $skip: Int, $after: String, $before: String, $first: Int, $last: Int) { allTodoes(filter: $filter, orderBy: $orderBy, skip: $skip, after: $after, before: $before, first: $first, last: $last) {
        ${resultSelector}
      } }`, variables, options)
    },
    queryTodo(variables, resultSelector = todoPrimitives, options = {}) {
      return self.query(`query Todo($id: ID) { Todo(id: $id) {
        ${resultSelector}
      } }`, variables, options)
    },
    mutateCreateTodo(variables, resultSelector = todoPrimitives, optimisticUpdate) {
      return self.mutate(`mutation createTodo($done: Boolean!, $isPublished: Boolean, $title: String!) { createTodo(done: $done, isPublished: $isPublished, title: $title) {
github mobxjs / mst-gql / examples / 5-nextjs / src / models / RootStore.base.ts View on Github external
import { UserModel, UserModelType } from "./UserModel"
import { userModelPrimitives, UserModelSelector } from "./UserModel.base"


/* The TypeScript type that explicits the refs to other models in order to prevent a circular refs issue */
type Refs = {
  todos: ObservableMap,
  users: ObservableMap
}

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = withTypedRefs()(MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Todo', () => TodoModel], ['User', () => UserModel]], ['Todo', 'User']))
  .props({
    todos: types.optional(types.map(types.late((): any => TodoModel)), {}),
    users: types.optional(types.map(types.late((): any => UserModel)), {})
  })
  .actions(self => ({
    queryTodos(variables?: {  }, resultSelector: string | ((qb: TodoModelSelector) => TodoModelSelector) = todoModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ todos: TodoModelType[]}>(`query todos { todos {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryDoneTodos(variables?: {  }, resultSelector: string | ((qb: TodoModelSelector) => TodoModelSelector) = todoModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ doneTodos: TodoModelType[]}>(`query doneTodos { doneTodos {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryUser(variables: { id: string }, resultSelector: string | ((qb: UserModelSelector) => UserModelSelector) = userModelPrimitives.toString(), options: QueryOptions = {}) {
github mobxjs / mst-gql / examples / 3-twitter-clone / src / app / models / RootStore.base.ts View on Github external
import { UserModel, UserModelType } from "./UserModel"
import { userModelPrimitives, UserModelSelector } from "./UserModel.base"


/* The TypeScript type that explicits the refs to other models in order to prevent a circular refs issue */
type Refs = {
  messages: ObservableMap,
  users: ObservableMap
}

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = withTypedRefs()(MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Message', () => MessageModel], ['User', () => UserModel]], ['Message', 'User']))
  .props({
    messages: types.optional(types.map(types.late((): any => MessageModel)), {}),
    users: types.optional(types.map(types.late((): any => UserModel)), {})
  })
  .actions(self => ({
    queryMessages(variables: { offset?: string, count?: number, replyTo?: string }, resultSelector: string | ((qb: MessageModelSelector) => MessageModelSelector) = messageModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ messages: MessageModelType[]}>(`query messages($offset: ID, $count: Int, $replyTo: ID) { messages(offset: $offset, count: $count, replyTo: $replyTo) {
        ${typeof resultSelector === "function" ? resultSelector(new MessageModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryMessage(variables: { id: string }, resultSelector: string | ((qb: MessageModelSelector) => MessageModelSelector) = messageModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ message: MessageModelType}>(`query message($id: ID!) { message(id: $id) {
        ${typeof resultSelector === "function" ? resultSelector(new MessageModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryMe(variables?: {  }, resultSelector: string | ((qb: UserModelSelector) => UserModelSelector) = userModelPrimitives.toString(), options: QueryOptions = {}) {
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / RootStore.base.ts View on Github external
import { MessageModel, MessageModelType } from "./MessageModel"
import { UserModel, UserModelType } from "./UserModel"


/* The TypeScript type that explicits the refs to other models in order to prevent a circular refs issue */
type Refs = {
  messages: ObservableMap,
  users: ObservableMap
}

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = withTypedRefs()(types.model()
  .named("RootStore")
  .extend(configureStoreMixin([['Message', () => MessageModel], ['User', () => UserModel]], ['Message', 'User']))
  .props({
    messages: types.optional(types.map(types.late((): any => MessageModel)), {}),
    users: types.optional(types.map(types.late((): any => UserModel)), {})
  })
  .actions(self => ({
  })))
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / RootStore.base.ts View on Github external
/* This is a mst-sql generated file, don't modify it manually */
/* eslint-disable */
/* tslint:disable */
import { types } from "mobx-state-tree"
import { MSTGQLStore, configureStoreMixin, QueryOptions } from "mst-gql"

import { MessageModel, UserModel, ReplyModel } from "./index"

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = types.model()
  .named("RootStore")
  .extend(configureStoreMixin([['Message', () => MessageModel], ['User', () => UserModel], ['Reply', () => ReplyModel]], ['Message', 'User']))
  .props({
    messages: types.optional(types.map(types.late(() => MessageModel)), {}),
    users: types.optional(types.map(types.late(() => UserModel)), {})
  })
  .actions(self => ({    
  }))
github mobxjs / mst-gql / examples / 1-getting-started / src / app / models / RootStore.base.ts View on Github external
export type CreateTodoInput = {
  id: string
  text: string
  complete?: boolean
}
/* The TypeScript type that explicits the refs to other models in order to prevent a circular refs issue */
type Refs = {
  todos: ObservableMap
}

/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = withTypedRefs()(MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['Todo', () => TodoModel]], ['Todo']))
  .props({
    todos: types.optional(types.map(types.late((): any => TodoModel)), {})
  })
  .actions(self => ({
    queryTodos(variables?: {  }, resultSelector: string | ((qb: TodoModelSelector) => TodoModelSelector) = todoModelPrimitives.toString(), options: QueryOptions = {}) {
      return self.query<{ todos: TodoModelType[]}>(`query todos { todos {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    mutateToggleTodo(variables: { id: string }, resultSelector: string | ((qb: TodoModelSelector) => TodoModelSelector) = todoModelPrimitives.toString(), optimisticUpdate?: () => void) {
      return self.mutate<{ toggleTodo: TodoModelType}>(`mutation toggleTodo($id: ID!) { toggleTodo(id: $id) {
        ${typeof resultSelector === "function" ? resultSelector(new TodoModelSelector()).toString() : resultSelector}
      } }`, variables, optimisticUpdate)
    },
    mutateCreateTodo(variables: { todo: CreateTodoInput }, resultSelector: string | ((qb: TodoModelSelector) => TodoModelSelector) = todoModelPrimitives.toString(), optimisticUpdate?: () => void) {
      return self.mutate<{ createTodo: TodoModelType}>(`mutation createTodo($todo: CreateTodoInput!) { createTodo(todo: $todo) {
github mobxjs / mst-gql / examples / 4-apollo-tutorial / client / src / models / RootStore.base.js View on Github external
import { LaunchModel } from "./LaunchModel"
import { launchModelPrimitives, LaunchModelSelector } from "./LaunchModel.base"
import { MissionModel } from "./MissionModel"
import { missionModelPrimitives, MissionModelSelector } from "./MissionModel.base"
import { RocketModel } from "./RocketModel"
import { rocketModelPrimitives, RocketModelSelector } from "./RocketModel.base"
import { UserModel } from "./UserModel"
import { userModelPrimitives, UserModelSelector } from "./UserModel.base"


/**
* Store, managing, among others, all the objects received through graphQL
*/
export const RootStoreBase = MSTGQLStore
  .named("RootStore")
  .extend(configureStoreMixin([['LaunchConnection', () => LaunchConnectionModel], ['Launch', () => LaunchModel], ['Mission', () => MissionModel], ['Rocket', () => RocketModel], ['User', () => UserModel]], ['Launch', 'Rocket', 'User']))
  .props({
    launchs: types.optional(types.map(types.late(() => LaunchModel)), {}),
    rockets: types.optional(types.map(types.late(() => RocketModel)), {}),
    users: types.optional(types.map(types.late(() => UserModel)), {})
  })
  .actions(self => ({
    queryLaunches(variables, resultSelector = launchConnectionModelPrimitives.toString(), options = {}) {
      return self.query(`query launches($pageSize: Int, $after: String) { launches(pageSize: $pageSize, after: $after) {
        ${typeof resultSelector === "function" ? resultSelector(new LaunchConnectionModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },
    queryLaunch(variables, resultSelector = launchModelPrimitives.toString(), options = {}) {
      return self.query(`query launch($id: ID!) { launch(id: $id) {
        ${typeof resultSelector === "function" ? resultSelector(new LaunchModelSelector()).toString() : resultSelector}
      } }`, variables, options)
    },