mirror of
https://github.com/wassname/talk.git
synced 2026-08-01 13:00:55 +08:00
Merge branch 'next' into next-respect
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
retrieveCommentAssetConnection,
|
||||
retrieveCommentParentsConnection,
|
||||
retrieveCommentRepliesConnection,
|
||||
retrieveCommentUserConnection,
|
||||
retrieveManyComments,
|
||||
} from "talk-server/models/comment";
|
||||
import { Connection } from "talk-server/models/connection";
|
||||
@@ -53,6 +54,20 @@ export default (ctx: Context) => ({
|
||||
itemIDs
|
||||
)
|
||||
),
|
||||
forUser: (
|
||||
userID: string,
|
||||
// Apply the graph schema defaults at the loader.
|
||||
{
|
||||
first = 10,
|
||||
orderBy = GQLCOMMENT_SORT.CREATED_AT_DESC,
|
||||
after,
|
||||
}: AssetToCommentsArgs
|
||||
) =>
|
||||
retrieveCommentUserConnection(ctx.mongo, ctx.tenant.id, userID, {
|
||||
first,
|
||||
orderBy,
|
||||
after,
|
||||
}),
|
||||
forAsset: (
|
||||
assetID: string,
|
||||
// Apply the graph schema defaults at the loader.
|
||||
|
||||
@@ -84,6 +84,8 @@ const Comment: GQLCommentTypeResolver<Comment> = {
|
||||
comment.parent_id
|
||||
? ctx.loaders.Comments.parents(comment, input)
|
||||
: createConnection(),
|
||||
asset: (comment, input, ctx) =>
|
||||
ctx.loaders.Assets.asset.load(comment.asset_id),
|
||||
};
|
||||
|
||||
export default Comment;
|
||||
|
||||
@@ -8,6 +8,7 @@ import CommentCounts from "./comment_counts";
|
||||
import Mutation from "./mutation";
|
||||
import Profile from "./profile";
|
||||
import Query from "./query";
|
||||
import User from "./user";
|
||||
|
||||
const Resolvers: GQLResolver = {
|
||||
Asset,
|
||||
@@ -18,6 +19,7 @@ const Resolvers: GQLResolver = {
|
||||
Mutation,
|
||||
Profile,
|
||||
Query,
|
||||
User,
|
||||
};
|
||||
|
||||
export default Resolvers;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { GQLUserTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { User } from "talk-server/models/user";
|
||||
|
||||
const User: GQLUserTypeResolver<User> = {
|
||||
comments: (user, input, ctx) => ctx.loaders.Comments.forUser(user.id, input),
|
||||
};
|
||||
|
||||
export default User;
|
||||
@@ -5,7 +5,7 @@
|
||||
"""
|
||||
auth is a directive that will enforce authorization rules on the schema
|
||||
definition. It will restrict the viewer of the field based on roles or if the
|
||||
`userIDField` is specified, it will see if the current users ID equals the field
|
||||
`userIDField` is specified, it will see if the current users ID equals the field
|
||||
specified. This allows users that own a specific resource (like a comment, or a
|
||||
flag) see their own content, but restrict it to everyone else. If the directive
|
||||
is used without options, it simply requires a logged in user.
|
||||
@@ -761,6 +761,15 @@ type User {
|
||||
role is the current role of the User.
|
||||
"""
|
||||
role: USER_ROLE! @auth(roles: [ADMIN, MODERATOR], userIDField: "id")
|
||||
|
||||
"""
|
||||
comments are the comments of the User.
|
||||
"""
|
||||
comments(
|
||||
first: Int = 10
|
||||
orderBy: COMMENT_SORT = CREATED_AT_DESC
|
||||
after: Cursor
|
||||
): CommentsConnection! @auth(roles: [ADMIN, MODERATOR], userIDField: "id")
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -897,6 +906,11 @@ type Comment {
|
||||
left by the current User on this Comment.
|
||||
"""
|
||||
myActionPresence: ActionPresence
|
||||
|
||||
"""
|
||||
asset is the Asset that the Comment was written on.
|
||||
"""
|
||||
asset: Asset!
|
||||
}
|
||||
|
||||
type PageInfo {
|
||||
|
||||
Reference in New Issue
Block a user