-
Notifications
You must be signed in to change notification settings - Fork 684
/
schema.graphqls
177 lines (150 loc) · 3.36 KB
/
schema.graphqls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Build the schema.
type Query {
article(slug: String!): Article
articles(
first: Int,
after: String,
last: Int,
before: String,
authoredBy: String
favoritedBy: String
withTag: String
): ArticlesConnection
me: User
feed(first: Int, after: String, last: Int, before: String): ArticlesConnection
profile(username: String!): ProfilePayload
tags: [String]
}
union UserResult = UserPayload | Error
type Mutation {
### User & Profile
createUser(input: CreateUserInput): UserResult
login(password: String!, email: String!): UserPayload
updateUser(changes: UpdateUserInput!): UserPayload
followUser(username: String!): ProfilePayload
unfollowUser(username: String!): ProfilePayload
### Article
createArticle(input: CreateArticleInput!): ArticlePayload
updateArticle(slug: String!, changes: UpdateArticleInput!): ArticlePayload
favoriteArticle(slug: String!): ArticlePayload
unfavoriteArticle(slug: String!): ArticlePayload
deleteArticle(slug: String!): DeletionStatus
### Comment
addComment(slug: String!, body: String!): CommentPayload
deleteComment(slug: String!, id: ID!): DeletionStatus
}
schema {
query: Query
mutation: Mutation
}
### Articles
type Article {
author: Profile!
body: String!
comments(first: Int, after: String, last: Int, before: String): CommentsConnection
createdAt: String!
description: String!
favorited: Boolean!
favoritesCount: Int!
slug: String!
tagList: [String],
title: String!
updatedAt: String!
}
type ArticleEdge {
cursor: String!
node: Article
}
type ArticlesConnection {
edges: [ArticleEdge]
pageInfo: PageInfo!
}
### Comments
type Comment {
id: ID!
author: Profile!
article: Article!
body: String!
createdAt: String!
updatedAt: String!
}
type CommentEdge {
cursor: String!
node: Comment
}
type CommentsConnection {
edges: [CommentEdge]
pageInfo: PageInfo!
}
type DeletionStatus {
success: Boolean!
}
type PageInfo {
endCursor: String
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
}
### Profile
type Profile {
username: String!
bio: String
following: Boolean!
image: String
articles(first: Int, after: String, last: Int, before: String): ArticlesConnection
favorites(first: Int, after: String, last: Int, before: String): ArticlesConnection
feed(first: Int, after: String, last: Int, before: String): ArticlesConnection
}
### User
type User {
email: String!
profile: Profile!
token: String!
username: String!
}
### Error
type Error {
message: String
errors: [ErrorItem!]
}
type ErrorItem {
key: String!
value: [String!]!
}
## Mutations
# Input types.
input UpdateArticleInput {
body: String
description: String
title: String
}
input CreateArticleInput {
body: String!
description: String!
tagList: [String]
title: String!
}
type ArticlePayload {
article: Article
}
type CommentPayload {
comment: Comment
}
input CreateUserInput {
email: String!
username: String!
password: String!
}
input UpdateUserInput {
email: String
username: String
password: String
image: String
bio: String
}
type UserPayload {
user: User
}
type ProfilePayload {
profile: Profile
}