social-network
social-network/schema.graphql
1
type User @aws_cognito_user_pools @aws_iam {
2
	id: ID!
3
	name: String!
4
	avatar: String!
5
	friends(nextToken: String): PaginatedUsers
6
	posts(limit: Int, nextToken: String): PaginatedPosts
7
}
8
9
type Post @aws_cognito_user_pools @aws_iam {
10
	id: ID!
11
	author: User!
12
	text: String!
13
	date: AWSDateTime!
14
	comments(limit: Int, nextToken: String): PaginatedComments!
15
}
16
17
type Comment @aws_cognito_user_pools @aws_iam {
18
	id: ID!
19
	post: Post!
20
	author: User!
21
	text: String!
22
	date: AWSDateTime!
23
}
24
25
type PaginatedUsers @aws_cognito_user_pools @aws_iam {
26
	users: [User!]!
27
	nextToken: String
28
}
29
30
type PaginatedComments @aws_cognito_user_pools @aws_iam {
31
	comments: [Comment!]!
32
	nextToken: String
33
}
34
35
type PaginatedPosts @aws_cognito_user_pools @aws_iam {
36
	posts: [Post!]!
37
	nextToken: String
38
}
39
40
type Query @aws_cognito_user_pools @aws_iam {
41
	currentUser: User!
42
	post(id: ID!): Post
43
	user(id: ID!): User
44
}
45
46
type Mutation @aws_cognito_user_pools @aws_iam {
47
	createPost(userId: ID!, text: String!): Post!
48
	addComment(userId: ID!, postId: ID!, text: String!): Comment!
49
50
	notifyPost(postId: ID!): PostEvent!
51
	@aws_iam
52
	notifyComment(commentId: ID!): CommentEvent!
53
	@aws_iam
54
}
55
56
type PostEvent @aws_cognito_user_pools @aws_iam {
57
	userId: ID!
58
	post: Post!
59
}
60
61
type CommentEvent @aws_cognito_user_pools @aws_iam {
62
	postUserId: ID!
63
	postDate: AWSDateTime!
64
	comment: Comment!
65
}
66
67
type Subscription {
68
	post(userId: ID!): PostEvent
69
	@aws_subscribe(mutations: ["notifyPost"])
70
	comment(postUserId: ID!, postDateStarting: AWSDateTime!): CommentEvent
71
	@aws_subscribe(mutations: ["notifyComment"])
72
}
73
74
schema {
75
	query: Query
76
	mutation: Mutation
77
	subscription: Subscription
78
}
79
80