Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
820ebd3
commit 6a84a91
Showing
23 changed files
with
601 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,4 +64,5 @@ typings/ | |
|
||
dist | ||
|
||
tmp_schema.json | ||
tmp_schema.json | ||
.awcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
examples/6-twitter-clone/tsconfig.json → ...les/6-twitter-clone/src/app/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"rootDir": "./src", | ||
"baseUrl": "./src", | ||
"rootDir": "./src/app", | ||
"baseUrl": "./src/app", | ||
"strict": false, | ||
"lib": ["dom", "es2018", "esnext.asynciterable", "esnext.array"], | ||
"jsx": "react", | ||
"esModuleInterop": true, | ||
"moduleResolution": "node" | ||
} | ||
"moduleResolution": "node", | ||
"isolatedModules": true | ||
}, | ||
"files": ["index.tsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"messages": { | ||
"abc": { | ||
"id": "abc", | ||
"timestamp": 1558081865759, | ||
"text": "#MobX is cool", | ||
"user": "mweststrate" | ||
}, | ||
"def": { | ||
"id": "def", | ||
"timestamp": 1558081465759, | ||
"text": "Chuck Norris doesn't believe in floating point numbers because they can't be typed on his binary keyboard.", | ||
"user": "chucknorris" | ||
}, | ||
"ghi": { | ||
"id": "ghi", | ||
"timestamp": 1558081462759, | ||
"text": "All arrays Chuck Norris declares are of infinite size, because Chuck Norris knows no bounds.", | ||
"user": "chucknorris" | ||
} | ||
}, | ||
"users": { | ||
"mweststrate": { | ||
"id": "mweststrate", | ||
"name": "Michel Weststrate", | ||
"avatar": "https://pbs.twimg.com/profile_images/1126182603944599558/BlES9eyZ_400x400.jpg" | ||
}, | ||
"chucknorris": { | ||
"id": "chucknorris", | ||
"name": "Chuck Norris", | ||
"avatar": "https://beardoholic.com/wp-content/uploads/2017/12/c74461ae2a9917a2482ac7b53f195b3c6e2fdd59e778c673256fb29d1b07f181.jpg" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
examples/6-twitter-clone/src/server/models/MessageModel.base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 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 { MessageModel } from "./MessageModel" | ||
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, | ||
replyTo: types.maybe(MSTGQLRef(types.late((): any => MessageModel))), | ||
}) | ||
.views(self => ({ | ||
get store() { | ||
return self.__getStore<typeof RootStore.Type>() | ||
} | ||
})) | ||
|
||
|
19 changes: 19 additions & 0 deletions
19
examples/6-twitter-clone/src/server/models/MessageModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MessageModelBase } from "./MessageModel.base" | ||
|
||
/* The TypeScript type of an instance of MessageModel */ | ||
export type MessageModelType = typeof MessageModel.Type | ||
|
||
|
||
|
||
/** | ||
* MessageModel | ||
*/ | ||
export const MessageModel = MessageModelBase | ||
.actions(self => ({ | ||
// This is just an auto-generated example action, which can be safely thrown away. | ||
// 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)) | ||
} | ||
})) |
20 changes: 20 additions & 0 deletions
20
examples/6-twitter-clone/src/server/models/RootStore.base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* 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 } 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]], ['Message', 'User'])) | ||
.props({ | ||
messages: types.optional(types.map(types.late(() => MessageModel)), {}), | ||
users: types.optional(types.map(types.late(() => UserModel)), {}) | ||
}) | ||
.actions(self => ({ | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { RootStoreBase } from "./RootStore.base" | ||
|
||
export type RootStoreType = typeof RootStore.Type | ||
|
||
export const RootStore = RootStoreBase | ||
.actions(self => ({ | ||
// This is just an auto-generated example action, which can be safely thrown away. | ||
// 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)) | ||
} | ||
})) |
29 changes: 29 additions & 0 deletions
29
examples/6-twitter-clone/src/server/models/UserModel.base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* 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 { RootStore } from "./index" | ||
|
||
/** | ||
* UserBase | ||
* auto generated base class for the model UserModel. | ||
*/ | ||
export const UserModelBase = MSTGQLObject | ||
.named('User') | ||
.props({ | ||
__typename: types.optional(types.literal("User"), "User"), | ||
id: types.identifier, | ||
name: types.string, | ||
avatar: types.string, | ||
}) | ||
.views(self => ({ | ||
get store() { | ||
return self.__getStore<typeof RootStore.Type>() | ||
} | ||
})) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { UserModelBase } from "./UserModel.base" | ||
|
||
/* The TypeScript type of an instance of UserModel */ | ||
export type UserModelType = typeof UserModel.Type | ||
|
||
|
||
|
||
/** | ||
* UserModel | ||
*/ | ||
export const UserModel = UserModelBase | ||
.actions(self => ({ | ||
// This is just an auto-generated example action, which can be safely thrown away. | ||
// 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)) | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* This is a mst-sql generated file, don't modify it manually */ | ||
/* eslint-disable */ | ||
/* tslint:disable */ | ||
|
||
export * from "./MessageModel" | ||
export * from "./UserModel" | ||
export * from "./RootStore" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
type User { | ||
id: ID | ||
name: String! | ||
avatar: String! | ||
} | ||
type Message { | ||
id: ID | ||
timestamp: Float! | ||
user: User! | ||
text: String! | ||
replyTo: Message | ||
} | ||
type Query { | ||
messages: [Message] | ||
message(id: ID!): Message | ||
me: User | ||
} | ||
type Subscription { | ||
newMessages: Message | ||
} | ||
type Mutation { | ||
changeName(id: ID!, name: String!): User | ||
} |
Oops, something went wrong.