How to use the mst-gql.MSTGQLRef 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 / 4-apollo-tutorial / client / src / models / User.js View on Github external
`

/* #endregion */

/* #region type-def */

/**
* User
*/
export const User = MSTGQLObject
  .named('User')
  .props({
    __typename: types.optional(types.literal("User"), "User"),
    id: types.identifier,
    email: types.string,
    trips: types.array(MSTGQLRef(types.late(() => Launch))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })) /* #endregion */
github mobxjs / mst-gql / tests / lib / abstractTypes / models / RepoModel.base.js View on Github external
import { ModelBase } from "./ModelBase"
import { OrganizationModel } from "./OrganizationModel"
import { OwnerModelSelector } from "./OwnerModelSelector"
import { UserModel } from "./UserModel"


/**
 * RepoBase
 * auto generated base class for the model RepoModel.
 */
export const RepoModelBase = ModelBase
  .named('Repo')
  .props({
    __typename: types.optional(types.literal("Repo"), "Repo"),
    id: types.identifier,
    owner: types.maybeNull(types.union(MSTGQLRef(types.late(() => UserModel)), MSTGQLRef(types.late(() => OrganizationModel)))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))

export class RepoModelSelector extends QueryBuilder {
  get id() { return this.__attr(`id`) }
  owner(builder) { return this.__child(`owner`, OwnerModelSelector, builder) }
}
export function selectFromRepo() {
  return new RepoModelSelector()
}

export const repoModelPrimitives = selectFromRepo()
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / MessageModel.base.ts View on Github external
}

/**
 * MessageBase
 * auto generated base class for the model MessageModel.
 */
export const MessageModelBase = withTypedRefs()(ModelBase
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    timestamp: types.union(types.undefined, types.number),
    user: types.union(types.undefined, MSTGQLRef(types.late((): any => UserModel))),
    text: types.union(types.undefined, types.string),
    likes: types.union(types.undefined, types.null, types.array(MSTGQLRef(types.late((): any => UserModel)))),
    replyTo: types.union(types.undefined, types.null, MSTGQLRef(types.late((): any => MessageModel))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })))
github mobxjs / mst-gql / examples / 4-apollo-tutorial / client / src / models / UserModel.base.js View on Github external
import { ModelBase } from "./ModelBase"
import { LaunchModel } from "./LaunchModel"
import { LaunchModelSelector } from "./LaunchModel.base"


/**
 * UserBase
 * auto generated base class for the model UserModel.
 */
export const UserModelBase = ModelBase
  .named('User')
  .props({
    __typename: types.optional(types.literal("User"), "User"),
    id: types.identifier,
    email: types.union(types.undefined, types.string),
    trips: types.union(types.undefined, types.array(types.union(types.null, MSTGQLRef(types.late(() => LaunchModel))))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  }))

export class UserModelSelector extends QueryBuilder {
  get id() { return this.__attr(`id`) }
  get email() { return this.__attr(`email`) }
  trips(builder) { return this.__child(`trips`, LaunchModelSelector, builder) }
}
export function selectFromUser() {
  return new UserModelSelector()
}
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / MessageModel.base.ts View on Github external
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 / 3-twitter-clone / src / server / models / MessageModel.base.ts View on Github external
replyTo: MessageModelType;
}

/**
 * MessageBase
 * auto generated base class for the model MessageModel.
 */
export const MessageModelBase = withTypedRefs()(ModelBase
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    timestamp: types.union(types.undefined, types.number),
    user: types.union(types.undefined, MSTGQLRef(types.late((): any => UserModel))),
    text: types.union(types.undefined, types.string),
    likes: types.union(types.undefined, types.null, types.array(MSTGQLRef(types.late((): any => UserModel)))),
    replyTo: types.union(types.undefined, types.null, MSTGQLRef(types.late((): any => MessageModel))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })))
github mobxjs / mst-gql / examples / 3-twitter-clone / src / app / models / MessageModel.base.ts View on Github external
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()
    }
  }))

export const messageModelPrimitives = `
__typename
id
timestamp
text
`
github mobxjs / mst-gql / examples / 3-twitter-clone / src / server / models / MessageModel.base.ts View on Github external
user: UserModelType;
  likes: IObservableArray;
  replyTo: MessageModelType;
}

/**
 * MessageBase
 * auto generated base class for the model MessageModel.
 */
export const MessageModelBase = withTypedRefs()(ModelBase
  .named('Message')
  .props({
    __typename: types.optional(types.literal("Message"), "Message"),
    id: types.identifier,
    timestamp: types.union(types.undefined, types.number),
    user: types.union(types.undefined, MSTGQLRef(types.late((): any => UserModel))),
    text: types.union(types.undefined, types.string),
    likes: types.union(types.undefined, types.null, types.array(MSTGQLRef(types.late((): any => UserModel)))),
    replyTo: types.union(types.undefined, types.null, MSTGQLRef(types.late((): any => MessageModel))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })))
github mobxjs / mst-gql / examples / 5-nextjs / src / models / TodoModel.base.ts View on Github external
type Refs = {
  assignee: UserModelType;
}

/**
 * TodoBase
 * auto generated base class for the model TodoModel.
 */
export const TodoModelBase = withTypedRefs()(ModelBase
  .named('Todo')
  .props({
    __typename: types.optional(types.literal("Todo"), "Todo"),
    id: types.identifier,
    text: types.union(types.undefined, types.string),
    done: types.union(types.undefined, types.boolean),
    assignee: types.union(types.undefined, types.null, MSTGQLRef(types.late((): any => UserModel))),
  })
  .views(self => ({
    get store() {
      return self.__getStore()
    }
  })))

export class TodoModelSelector extends QueryBuilder {
  get id() { return this.__attr(`id`) }
  get text() { return this.__attr(`text`) }
  get done() { return this.__attr(`done`) }
  assignee(builder?: string | UserModelSelector | ((selector: UserModelSelector) => UserModelSelector)) { return this.__child(`assignee`, UserModelSelector, builder) }
}
export function selectFromTodo() {
  return new TodoModelSelector()
}