Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active August 19, 2020 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabit3/6762eed3f7ac098756e67abdc74cfdb2 to your computer and use it in GitHub Desktop.
Save dabit3/6762eed3f7ac098756e67abdc74cfdb2 to your computer and use it in GitHub Desktop.
AppSync Chat Schema
type Message {
id: ID!
content: String!
owner: String
createdAt: String
roomId: ID
}
type Room {
id: ID!
name: String
messages(
sortDirection: ModelSortDirection,
limit: Int,
nextToken: String
): MessageConnection
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
enum ModelSortDirection {
ASC
DESC
}
type MessageConnection {
items: [Message]
nextToken: String
}
type RoomConnection {
items: [Room]
nextToken: String
}
type Query {
getRoom(id: ID): Room
listMessagesForRoom(roomId: ID, sortDirection: ModelSortDirection): MessageConnection
listRooms(limit: Int): RoomConnection
}
type Mutation {
createMessage(input: MessageInput): Message
createRoom(input: RoomInput): Room
}
input MessageInput {
id: ID
content: String!
owner: String
createdAt: String
roomId: ID
}
input RoomInput {
id: ID
name: String
}
type Subscription {
onCreateRoom: Room
@aws_subscribe(mutations: ["createRoom"])
onCreateMessageByRoomId(roomId: ID): Message
@aws_subscribe(mutations: ["createMessage"])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment