165 lines
3.2 KiB
GraphQL
165 lines
3.2 KiB
GraphQL
# 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]
|
|
}
|
|
|
|
type Mutation {
|
|
### User & Profile
|
|
createUser(input: CreateUserInput): UserPayload
|
|
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!
|
|
}
|
|
|
|
## 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
|
|
}
|
|
|