# ===============================================
# COMMENT
# ===============================================

extend type Query {
  commentsProviders: [CommentProvider]

  comments(
    locale: String!
    path: String!
  ): [CommentPost]!

  commentById(
    id: Int!
  ): CommentPost
}

extend type Mutation {
  updateCommentsProviders(
    providers: [CommentProviderInput]
  ): DefaultResponse

  createComment(
    pageId: Int!
    replyTo: Int
    content: String!
    guestName: String
    guestEmail: String
  ): CommentCreateResponse  @rateLimit(limit: 1, duration: 15)

  updateComment(
    id: Int!
    content: String!
  ): CommentUpdateResponse

  deleteComment(
    id: Int!
  ): DefaultResponse
}

# -----------------------------------------------
# TYPES
# -----------------------------------------------

type CommentProvider {
  isEnabled: Boolean
  key: String
  title: String
  description: String
  logo: String
  website: String
  isAvailable: Boolean
  config: [KeyValuePair]
}

input CommentProviderInput {
  isEnabled: Boolean!
  key: String!
  config: [KeyValuePairInput]
}

type CommentPost {
  id: Int
  content: String
  render: String
  authorId: Int
  authorName: String
  authorEmail: String
  authorIP: String
  createdAt: Date
  updatedAt: Date
}

type CommentCreateResponse {
  operation: Operation
  id: Int
}

type CommentUpdateResponse {
  operation: Operation
  render: String
}