Skip to content

Commit

Permalink
chore: update GraphQL types
Browse files Browse the repository at this point in the history
- new API
- more non-nulls
  • Loading branch information
MrOrz committed Oct 9, 2023
1 parent 7c79bd3 commit 2b6dcc9
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 48 deletions.
62 changes: 38 additions & 24 deletions src/graphql/cofacts-api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Query {
"""
GetUser(id: String, slug: String): User
GetCategory(id: String): Category
GetYdoc(id: String!): Ydoc
ListArticles(
filter: ListArticleFilter
orderBy: [ListArticleOrderBy]
Expand Down Expand Up @@ -176,13 +177,13 @@ type Query {
type Article implements Node {
id: ID!
text: String
createdAt: String
createdAt: String!
updatedAt: String
status: ReplyRequestStatusEnum!
references: [ArticleReference]

"""Number of normal article replies"""
replyCount: Int
replyCount: Int!

"""
Connections between this article and replies. Sorted by the logic described in https://github.com/cofacts/rumors-line-bot/issues/78.
Expand All @@ -207,7 +208,7 @@ type Article implements Node {

"""Only list the articleReplies created by the currently logged in user"""
selfOnly: Boolean
): [ArticleReply]
): [ArticleReply!]!

"""
Automated reply from AI before human fact checkers compose an fact check
Expand All @@ -224,10 +225,10 @@ type Article implements Node {

"""Returns only article categories with the specified statuses"""
statuses: [ArticleCategoryStatusEnum!] = [NORMAL]
): [ArticleCategory]
): [ArticleCategory!]!

"""Number of normal article categories"""
categoryCount: Int
categoryCount: Int!
replyRequests(
"""Returns only article replies with the specified statuses"""
statuses: [ReplyRequestStatusEnum!] = [NORMAL]
Expand Down Expand Up @@ -258,7 +259,7 @@ type Article implements Node {
Specify a cursor, returns results before this cursor. cannot be used with "after".
"""
before: String
): ArticleConnection
): ArticleConnection!

"""Hyperlinks in article text"""
hyperlinks: [Hyperlink]
Expand Down Expand Up @@ -293,8 +294,8 @@ enum ReplyRequestStatusEnum {
}

type ArticleReference {
createdAt: String
type: ArticleReferenceTypeEnum
createdAt: String!
type: ArticleReferenceTypeEnum!
permalink: String
}

Expand All @@ -311,33 +312,33 @@ enum ArticleReferenceTypeEnum {

"""The linkage between an Article and a Reply"""
type ArticleReply {
replyId: String
replyId: String!
reply: Reply

"""Cached reply type value stored in ArticleReply"""
replyType: ReplyTypeEnum
articleId: String
articleId: String!
article: Article

"""The user who conencted this reply and this article."""
user: User
userId: String!
appId: String!
canUpdateStatus: Boolean
feedbackCount: Int
positiveFeedbackCount: Int
negativeFeedbackCount: Int
canUpdateStatus: Boolean!
feedbackCount: Int!
positiveFeedbackCount: Int!
negativeFeedbackCount: Int!
feedbacks(
"""Returns only aricle reply feedbacks with the specified statuses"""
statuses: [ArticleReplyFeedbackStatusEnum!] = [NORMAL]
): [ArticleReplyFeedback]
): [ArticleReplyFeedback!]!

"""
The feedback of current user. null when not logged in or not voted yet.
"""
ownVote: FeedbackVote
status: ArticleReplyStatusEnum
createdAt: String
status: ArticleReplyStatusEnum!
createdAt: String!
updatedAt: String
}

Expand All @@ -346,17 +347,17 @@ type Reply implements Node {

"""The user submitted this reply version"""
user: User
createdAt: String
createdAt: String!
text: String
type: ReplyTypeEnum
type: ReplyTypeEnum!
reference: String
articleReplies(
"""Deprecated. Please use statuses instead."""
status: ArticleReplyStatusEnum

"""Returns only article replies with the specified statuses"""
statuses: [ArticleReplyStatusEnum!] = [NORMAL]
): [ArticleReply]
): [ArticleReply!]!

"""
Hyperlinks in reply text or reference. May be empty array if no URLs are included. `null` when hyperlinks are still fetching.
Expand All @@ -379,7 +380,7 @@ type Reply implements Node {
Specify a cursor, returns results before this cursor. cannot be used with "after".
"""
before: String
): ReplyConnection
): ReplyConnection!
}

type User implements Node {
Expand Down Expand Up @@ -979,6 +980,21 @@ type Cooccurrence implements Node {
updatedAt: String!
}

type Ydoc {
"""Binary that stores as base64 encoded string"""
data: String

"""Ydoc snapshots which are used to restore to specific version"""
versions: [YdocVersion]
}

type YdocVersion {
createdAt: String

"""Binary that stores as base64 encoded string"""
snapshot: String
}

input ListArticleFilter {
"""Show only articles created by a specific app."""
appId: String
Expand Down Expand Up @@ -1557,9 +1573,7 @@ type Mutation {
articleType: ArticleTypeEnum!
reference: ArticleReferenceInput!

"""
The reason why the user want to submit this article. Mandatory for 1st sender
"""
"""The reason why the user want to submit this article"""
reason: String
): MutationResult

Expand Down
10 changes: 10 additions & 0 deletions typegen/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* Therefore it is highly recommended to use the babel or swc plugin for production.
*/
const documents = {
"\n query GetArticleInChoosingArticle($id: String!) {\n GetArticle(id: $id) {\n text\n replyCount\n articleType\n articleReplies(status: NORMAL) {\n reply {\n id\n type\n text\n }\n positiveFeedbackCount\n negativeFeedbackCount\n }\n }\n }\n ": types.GetArticleInChoosingArticleDocument,
"\n mutation SubmitReplyRequestWithoutReason($id: String!) {\n CreateOrUpdateReplyRequest(articleId: $id) {\n replyRequestCount\n }\n }\n ": types.SubmitReplyRequestWithoutReasonDocument,
"\n query ListArticlesInInitState($text: String!) {\n ListArticles(\n filter: { moreLikeThis: { like: $text } }\n orderBy: [{ _score: DESC }]\n first: 4\n ) {\n edges {\n node {\n text\n id\n articleType\n }\n highlight {\n text\n hyperlinks {\n title\n summary\n }\n }\n }\n }\n }\n ": types.ListArticlesInInitStateDocument,
"\n query ListArticlesInProcessMedia($mediaUrl: String!) {\n ListArticles(\n filter: {\n mediaUrl: $mediaUrl\n articleTypes: [TEXT, IMAGE, AUDIO, VIDEO]\n transcript: { shouldCreate: true }\n }\n orderBy: [{ _score: DESC }]\n first: 9\n ) {\n edges {\n score\n mediaSimilarity\n node {\n id\n articleType\n attachmentUrl(variant: THUMBNAIL)\n }\n highlight {\n text\n hyperlinks {\n title\n summary\n }\n }\n }\n }\n }\n ": types.ListArticlesInProcessMediaDocument,
"fragment CreateReferenceWordsReply on Reply {\n reference\n type\n}\n\nfragment CreateReplyMessagesReply on Reply {\n text\n ...CreateReferenceWordsReply\n}\n\nfragment CreateReplyMessagesArticle on Article {\n replyCount\n}\n\nfragment CreateHighlightContentsHighlight on Highlights {\n text\n hyperlinks {\n title\n summary\n }\n}": types.CreateReferenceWordsReplyFragmentDoc,
Expand All @@ -33,6 +35,14 @@ const documents = {
*/
export function graphql(source: string): unknown;

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query GetArticleInChoosingArticle($id: String!) {\n GetArticle(id: $id) {\n text\n replyCount\n articleType\n articleReplies(status: NORMAL) {\n reply {\n id\n type\n text\n }\n positiveFeedbackCount\n negativeFeedbackCount\n }\n }\n }\n "): (typeof documents)["\n query GetArticleInChoosingArticle($id: String!) {\n GetArticle(id: $id) {\n text\n replyCount\n articleType\n articleReplies(status: NORMAL) {\n reply {\n id\n type\n text\n }\n positiveFeedbackCount\n negativeFeedbackCount\n }\n }\n }\n "];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n mutation SubmitReplyRequestWithoutReason($id: String!) {\n CreateOrUpdateReplyRequest(articleId: $id) {\n replyRequestCount\n }\n }\n "): (typeof documents)["\n mutation SubmitReplyRequestWithoutReason($id: String!) {\n CreateOrUpdateReplyRequest(articleId: $id) {\n replyRequestCount\n }\n }\n "];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
Loading

0 comments on commit 2b6dcc9

Please sign in to comment.