How to use the mst-gql.MSTGQLObject.named 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 / examples / 3-using-subscriptions / src / app / models / Query.ts View on Github external
/* #endregion */

/* #region fragments */
export const queryPrimitives = `
id
__typename
`

/* #endregion */

/* #region type-def */

/**
* Query
*/
const Query = MSTGQLObject
.named('Query')
.props({
    messages: types.array(types.reference(types.late(() => Message))),
})
/* #endregion */

  .actions(self => ({
  // this is just an auto-generated example action. 
  // Feel free to add your own actions, props, views etc to the model. 
  // Any code outside the '#region mst-gql-*'  regions will be preserved
  log() {
    console.log(JSON.stringify(self))
  }
}))

export { Query }
github mobxjs / mst-gql / examples / 3-using-subscriptions / src / app / models / Subscription.ts View on Github external
/* #endregion */

/* #region fragments */
export const subscriptionPrimitives = `
id
__typename
`

/* #endregion */

/* #region type-def */

/**
* Subscription
*/
const Subscription = MSTGQLObject
.named('Subscription')
.props({
    newMessages: types.maybe(types.reference(types.late(() => Message))),
})
/* #endregion */

  .actions(self => ({
  // this is just an auto-generated example action. 
  // Feel free to add your own actions, props, views etc to the model. 
  // Any code outside the '#region mst-gql-*'  regions will be preserved
  log() {
    console.log(JSON.stringify(self))
  }
}))

export { Subscription }
github mobxjs / mst-gql / examples / 2-scaffolding / src / models / Query.ts View on Github external
/* #region fragments */
export const queryPrimitives = `
id
__typename
`

/* #endregion */

/* #region type-def */

/**
* Query
 *
 * Query any Pokémon by number or name
*/
const Query = MSTGQLObject
  .named('Query')
  .props({
    query: types.maybe(types.reference(types.late((): any => Query))),
  })
/* #endregion */

  .actions(self => ({
    // this is just an auto-generated example action. 
    // Feel free to add your own actions, props, views etc to the model. 
    // Any code outside the '#region mst-gql-*'  regions will be preserved
    log() {
      console.log(JSON.stringify(self))
    }
  }))

export { Query }
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / MessageModel.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 { MSTGQLObject, MSTGQLRef } from "mst-gql"

import { UserModel } from "./UserModel"
import { ReplyModel } from "./ReplyModel"
import { RootStore } from "./index"

/**
 * MessageBase
 * auto generated base class for the model MessageModel.
 */
export const MessageModelBase = MSTGQLObject
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    timestamp: types.number,
    user: MSTGQLRef(types.late(() => UserModel)),
    text: types.string,
    likes: types.array(MSTGQLRef(types.late(() => UserModel))),
    replies: types.array(types.late(() => ReplyModel)),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))
github mobxjs / mst-gql / examples / 4-apollo-tutorial / client / src / models / LaunchConnection.js View on Github external
export const launchConnectionPrimitives = `
__typename
cursor
hasMore
`

/* #endregion */

/* #region type-def */

/**
* LaunchConnection
 *
 * Simple wrapper around our list of launches that contains a cursor to the last item in the list. Pass this cursor to the launches query to fetch results after these.
*/
export const LaunchConnection = MSTGQLObject
  .named('LaunchConnection')
  .props({
    __typename: types.optional(types.literal("LaunchConnection"), "LaunchConnection"),
    cursor: types.string,
    hasMore: types.boolean,
    launches: types.array(MSTGQLRef(types.late(() => Launch))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })) /* #endregion */
  .volatile(self => ({
    isFetchingMore: false
  }))
  .actions(self => ({
github mobxjs / mst-gql / examples / 2-scaffolding / src / models / PokemonEvolutionRequirement.ts View on Github external
__typename
amount
name
`

/* #endregion */

/* #region type-def */
export type PokemonEvolutionRequirementType = typeof PokemonEvolutionRequirement.Type

/**
* PokemonEvolutionRequirement
 *
 * Represents a Pokémon's requirement to evolve
*/
export const PokemonEvolutionRequirement = MSTGQLObject
  .named('PokemonEvolutionRequirement')
  .props({
    __typename: types.optional(types.literal("PokemonEvolutionRequirement"), "PokemonEvolutionRequirement"),
    /** The amount of candy to evolve */
    amount: types.optional(types.integer, 0),
    /** The name of the candy to evolve */
    name: types.optional(types.string, ''),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))
/* #endregion */

  .actions(self => ({
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / ReplyModel.base.ts View on Github external
/* This is a mst-gql generated file, don't modify it manually */
/* eslint-disable */
/* tslint:disable */

import { types } from "mobx-state-tree"
import { MSTGQLObject, MSTGQLRef } from "mst-gql"

import { UserModel } from "./UserModel"
import { RootStore } from "./index"

/**
 * ReplyBase
 * auto generated base class for the model ReplyModel.
 */
export const ReplyModelBase = MSTGQLObject
  .named('Reply')
  .props({
    __typename: types.optional(types.literal("Reply"), "Reply"),
    id: types.identifier,
    timestamp: types.number,
    user: MSTGQLRef(types.late(() => UserModel)),
    text: types.string,
    likes: types.array(MSTGQLRef(types.late(() => UserModel))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))
github mobxjs / mst-gql / examples / 3-using-subscriptions / src / app / models / Message.ts View on Github external
export const messagePrimitives = `
__typename
id
from
message
`

/* #endregion */

/* #region type-def */
export type MessageType = typeof Message.Type

/**
* Message
*/
export const Message = MSTGQLObject
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    from: types.optional(types.string, ''),
    message: types.optional(types.string, ''),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))
/* #endregion */
github mobxjs / mst-gql / examples / 3-twitter-clone / src / app / models / MessageModel.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 { MSTGQLObject, MSTGQLRef } from "mst-gql"

import { UserModel } from "./UserModel"
import { ReplyModel } from "./ReplyModel"
import { RootStore } from "./index"

/**
 * MessageBase
 * auto generated base class for the model MessageModel.
 */
export const MessageModelBase = MSTGQLObject
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    timestamp: types.number,
    user: MSTGQLRef(types.late(() => UserModel)),
    text: types.string,
    likes: types.array(MSTGQLRef(types.late(() => UserModel))),
    replies: types.array(types.late(() => ReplyModel)),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))
github mobxjs / mst-gql / examples / 5-todos / src / models / Todo.js View on Github external
createdAt
done
id
isPublished
title
updatedAt
`

/* #endregion */

/* #region type-def */

/**
* Todo
*/
export const Todo = MSTGQLObject
  .named('Todo')
  .props({
    __typename: types.optional(types.literal("Todo"), "Todo"),
    createdAt: types.frozen(),
    done: types.boolean,
    id: types.identifier,
    /** Indicates if the record is published */
    isPublished: types.boolean,
    title: types.string,
    updatedAt: types.frozen(),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })) /* #endregion */