Browse Source

Merge pull request #2159 from ondratra/query_node_input_schema

Query node input schema
Mokhtar Naamani 4 years ago
parent
commit
a0a32efa91
1 changed files with 196 additions and 175 deletions
  1. 196 175
      query-node/schema.graphql

+ 196 - 175
query-node/schema.graphql

@@ -1,3 +1,8 @@
+# temporary type used before `DateTime` type is working
+type DateTime @entity {
+  timestamp: BigInt!
+}
+
 enum Network {
   BABYLON
   ALEXANDRIA
@@ -8,17 +13,23 @@ type Block @entity {
   "Block number as a string"
   id: ID!
   block: Int!
-  timestamp: BigInt!
+  executedAt: DateTime!
   network: Network!
 }
 
+enum MembershipEntryMethod {
+  PAID
+  SCREENING
+  GENESIS
+}
+
 "Stored information about a registered user"
-type Member @entity {
+type Membership @entity {
   "MemberId: runtime identifier for a user"
   id: ID!
 
   "The unique handle chosen by member"
-  handle: String @unique @fulltext(query: "membersByHandle")
+  handle: String! @unique @fulltext(query: "membersByHandle")
 
   "A Url to member's Avatar image"
   avatarUri: String
@@ -26,205 +37,216 @@ type Member @entity {
   "Short text chosen by member to share information about themselves"
   about: String
 
-  "Blocknumber when member was registered"
-  registeredAtBlock: Int!
-
   "Member's controller account id"
-  controllerAccount: Bytes!
+  controllerAccount: String!
 
   "Member's root account id"
-  rootAccount: Bytes!
+  rootAccount: String!
 
-  happenedIn: Block!
-}
+  "Blocknumber when member was registered"
+  registeredAtBlock: Block!
 
-"""
-This type is to keep which entity belongs to which class. This type will be used
-by EntityCreated event. When a new schema support added to an Entity we will get the
-class name from this table.
-We need this because we can't create a database row (Channel, Video etc) without
-with empty fields.
-"""
-type ClassEntity @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+  "Timestamp when member was registered"
+  registeredAtTime: DateTime!
 
-  "The class id of this entity"
-  classId: Int!
+  "How the member was registered"
+  entry: MembershipEntryMethod!
 
-  happenedIn: Block!
+  "The type of subscription the member has purchased if any."
+  subscription: BigInt
 }
 
-"Keep track of the next entity id"
-type NextEntityId @entity {
-  "Constant field is set to '1'"
+"Category of media channel"
+type ChannelCategory @entity {
   id: ID!
 
-  nextId: Int!
+  "The name of the category"
+  name: String @fulltext(query: "channelCategoriesByName")
+
+  channels: [Channel!] @derivedFrom(field: "category")
+
+  happenedIn: Block!
 }
 
-#### High Level Derivative Entities ####
+"Storage asset"
+union Asset = AssetUrl | AssetStorage
 
-type Language @entity {
-  "Runtime entity identifier (EntityId)"
+"Asset stored at an external source"
+type AssetUrl @variant {
   id: ID!
 
-  name: String!
-  code: String!
+  "The http url pointing to the media"
+  url: String!
+}
 
+"Asset was never fully uploaded."
+type AssetNeverProvided @variant {
   happenedIn: Block!
 }
 
-type Channel @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
-
-  # "Owner of the channel" Commenting out this field: 'owner' can be curator_group, lead
-  # or a member. We are not handling events related to curator group so we will not set this field
-  # owner: Member!
-
-  "The title of the Channel"
-  handle: String! @fulltext(query: "search")
+"Asset was deleted and is no longer available."
+type AssetDeleted @variant {
+  happenedIn: Block!
+}
 
-  "The description of a Channel"
-  description: String!
+"Status of an asset upload"
+type AssetUploadStatus @variant {
+  """
+  Data object in upload life-cycle.
+  If this is deleted, then set oldDataObject in its place if it is set and not rejected, otherwise union goes to Deleted.
+  """
+  dataObject: AssetDataObject!
+
+  """
+  Possible prior data object which was in some stage of upload life-cycle when new one was initiated.
+  If accepted, then apps may chose to use old in place of new before it is accepted.
+  If this is deleted, then set to null.
+  """
+  oldDataObject: AssetDataObject
 
-  "Url for Channel's cover (background) photo. Recommended ratio: 16:9."
-  coverPhotoUrl: String
+  happenedIn: Block!
+}
 
-  "Channel's avatar photo."
-  avatarPhotoUrl: String
+union AssetStorageUploadStatus = AssetNeverProvided | AssetDeleted | AssetUploadStatus
 
-  "Flag signaling whether a channel is public."
-  isPublic: Boolean!
+type AssetStorage @variant {
+  id: ID!
 
-  "Flag signaling whether a channel is curated/verified."
-  isCurated: Boolean!
+  "Upload to content directory status"
+  uploadStatus: AssetStorageUploadStatus!
+}
 
-  "The primary langauge of the channel's content"
-  language: Language
+"The decision of the storage provider when it acts as liaison"
+enum LiaisonJudgement {
+  "Content awaits for a judgment"
+  PENDING,
 
-  videos: [Video!] @derivedFrom(field: "channel")
+  "Content accepted"
+  ACCEPTED,
 
-  happenedIn: Block!
+  "Content rejected"
+  REJECTED,
 }
 
-type Category @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+"Manages content ids, type and storage provider decision about it"
+type AssetDataObject @entity {
+  "Content owner"
+  owner: AssetOwner!
 
-  "The name of the category"
-  name: String! @unique @fulltext(query: "categoriesByName")
+  "Content added at"
+  addedAt: Block!
 
-  "The description of the category"
-  description: String
+  "Content type id"
+  typeId: Int!
 
-  videos: [Video!] @derivedFrom(field: "category")
+  "Content size in bytes"
+  size: BigInt!
 
-  happenedIn: Block!
-}
+  "Storage provider id of the liaison"
+  liaisonId: BigInt!
 
-"Encoding and containers"
-type VideoMediaEncoding @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+  "Storage provider as liaison judgment"
+  liaisonJudgement: LiaisonJudgement!
 
-  name: String!
+  "IPFS content id"
+  ipfsContentId: String!
 
-  happenedIn: Block!
+  "Joystream runtime content"
+  joystreamContentId: String!
 }
 
-type KnownLicenseEntity @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+"Owner type for storage object"
+union AssetOwner = AssetOwnerMember | AssetOwnerChannel | AssetOwnerDao | AssetOwnerCouncil | AssetOwnerWorkingGroup
 
-  "Short, commonly recognized code of the licence (ie. CC_BY_SA)"
-  code: String! @unique
+"Asset owned by a member"
+type AssetOwnerMember @variant {
+  "Member identifier"
+  memberId: BigInt!
+}
 
-  "Full, descriptive name of the license (ie. Creative Commons - Attribution-NonCommercial-NoDerivs)"
-  name: String
+"Asset owned by a channel"
+type AssetOwnerChannel @variant {
+  "Channel identifier"
+  channel: Channel!
+}
 
-  "Short description of the license conditions"
-  description: String
+"Asset owned by a DAO"
+type AssetOwnerDao @variant {
+  "DAO identifier"
+  daoId: BigInt!
+}
 
-  "An url pointing to full license content"
-  url: String
+"Asset owned by the Council"
+type AssetOwnerCouncil @variant {
+  "Variant needs to have at least one property. This value is not used."
+  dummy: Int!
+}
 
-  happenedIn: Block!
+"Asset owned by a WorkingGroup"
+type AssetOwnerWorkingGroup @variant {
+  "Working group identifier"
+  workingGroupId: BigInt!
 }
 
-type UserDefinedLicenseEntity @entity {
+#### High Level Derivative Entities ####
+
+type Language @entity {
   "Runtime entity identifier (EntityId)"
   id: ID!
 
-  "Custom license content"
-  content: String!
+  "Language identifier ISO 639-1"
+  iso: String!
 
   happenedIn: Block!
 }
 
-type MediaLocationEntity @entity {
+type Channel @entity {
   "Runtime entity identifier (EntityId)"
   id: ID!
 
-  # One of the following field will be non-null
+  # "Owner of the channel" Commenting out this field: 'owner' can be curator_group, lead
+  # or a member. We are not handling events related to curator group so we will not set this field
+  # owner: Member!
 
-  "A reference to HttpMediaLocation"
-  httpMediaLocation: HttpMediaLocationEntity
+  category: ChannelCategory
 
-  "A reference to JoystreamMediaLocation"
-  joystreamMediaLocation: JoystreamMediaLocationEntity
+  "Reward account where revenue is sent if set."
+  rewardAccount: String
 
-  videoMedia: VideoMedia @derivedFrom(field: "locationEntity")
+  "The title of the Channel"
+  title: String @fulltext(query: "search")
 
-  happenedIn: Block!
-}
+  "The description of a Channel"
+  description: String
 
-type JoystreamMediaLocationEntity @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+  "Channel's cover (background) photo. Recommended ratio: 16:9."
+  coverPhoto: Asset
 
-  "Id of the data object in the Joystream runtime dataDirectory module"
-  dataObjectId: String! @unique
+  "Channel's avatar photo."
+  avatarPhoto: Asset
 
-  happenedIn: Block!
-}
+  "Flag signaling whether a channel is public."
+  isPublic: Boolean
 
-type HttpMediaLocationEntity @entity {
-  "Runtime entity identifier (EntityId)"
-  id: ID!
+  "Flag signaling whether a channel is censored."
+  isCensored: Boolean!
 
-  "The http url pointing to the media"
-  url: String!
+  "The primary langauge of the channel's content"
+  language: Language
 
-  "The port to use when connecting to the http url (defaults to 80)"
-  port: Int
+  videos: [Video!] @derivedFrom(field: "channel")
 
   happenedIn: Block!
 }
 
-type VideoMedia @entity {
+type VideoCategory @entity {
   "Runtime entity identifier (EntityId)"
   id: ID!
 
-  "Encoding of the video media object"
-  encoding: VideoMediaEncoding!
-
-  "Video media width in pixels"
-  pixelWidth: Int!
-
-  "Video media height in pixels"
-  pixelHeight: Int!
-
-  "Video media size in bytes"
-  size: Int
-
-  video: Video @derivedFrom(field: "media")
-
-  "Location of the video media object"
-  location: MediaLocation!
+  "The name of the category"
+  name: String @fulltext(query: "videoCategoriesByName")
 
-  locationEntity: MediaLocationEntity
+  videos: [Video!] @derivedFrom(field: "category")
 
   happenedIn: Block!
 }
@@ -237,45 +259,46 @@ type Video @entity {
   channel: Channel!
 
   "Reference to a video category"
-  category: Category!
+  category: VideoCategory
 
   "The title of the video"
-  title: String! @fulltext(query: "search")
+  title: String @fulltext(query: "search")
 
   "The description of the Video"
-  description: String!
+  description: String
 
   "Video duration in seconds"
-  duration: Int!
+  duration: Int
 
-  "Video's skippable intro duration in seconds"
-  skippableIntroDuration: Int
-
-  "Video thumbnail url (recommended ratio: 16:9)"
-  thumbnailUrl: String!
+  "Video thumbnail (recommended ratio: 16:9)"
+  thumbnail: Asset
 
   "Video's main langauge"
   language: Language
 
-  "Reference to VideoMedia"
-  media: VideoMedia!
-
   "Whether or not Video contains marketing"
   hasMarketing: Boolean
 
   "If the Video was published on other platform before beeing published on Joystream - the original publication date"
-  publishedBeforeJoystream: Int
+  publishedBeforeJoystream: DateTime
 
   "Whether the Video is supposed to be publically displayed"
-  isPublic: Boolean!
+  isPublic: Boolean
 
-  "Video curation status set by the Curator"
-  isCurated: Boolean!
+  "Flag signaling whether a video is censored."
+  isCensored: Boolean!
 
   "Whether the Video contains explicit material."
-  isExplicit: Boolean!
+  isExplicit: Boolean
 
-  license: LicenseEntity!
+  "License under the video is published"
+  license: License
+
+  "Reference to video asset"
+  media: Asset
+
+  "Video file metadata"
+  mediaMetadata: VideoMediaMetadata
 
   happenedIn: Block!
 
@@ -285,52 +308,50 @@ type Video @entity {
   featured: FeaturedVideo @derivedFrom(field: "video")
 }
 
-type JoystreamMediaLocation @variant {
-  "Id of the data object in the Joystream runtime dataDirectory module"
-  dataObjectId: String!
-}
-
-type HttpMediaLocation @variant {
-  "The http url pointing to the media"
-  url: String!
+type VideoMediaMetadata @entity {
+  "Runtime entity identifier (EntityId)"
+  id: ID!
 
-  "The port to use when connecting to the http url (defaults to 80)"
-  port: Int
-}
+  "Encoding of the video media object"
+  encoding: VideoMediaEncoding
 
-union MediaLocation = HttpMediaLocation | JoystreamMediaLocation
+  "Video media width in pixels"
+  pixelWidth: Int
 
-type KnownLicense @variant {
-  "Short, commonly recognized code of the licence (ie. CC_BY_SA)"
-  code: String!
+  "Video media height in pixels"
+  pixelHeight: Int
 
-  "Full, descriptive name of the license (ie. Creative Commons - Attribution-NonCommercial-NoDerivs)"
-  name: String
+  "Video media size in bytes"
+  size: Int
 
-  "Short description of the license conditions"
-  description: String
+  video: Video @derivedFrom(field: "mediaMetadata")
 
-  "An url pointing to full license content"
-  url: String
+  happenedIn: Block!
 }
 
-type UserDefinedLicense @variant {
-  "Custom license content"
-  content: String!
-}
+type VideoMediaEncoding @entity {
+  "Encoding of the video media object"
+  codecName: String
 
-union License = KnownLicense | UserDefinedLicense
+  "Media container format"
+  container: String
 
-type LicenseEntity @entity {
+  "Content MIME type"
+  mimeMediaType: String
+}
+
+type License @entity {
   "Runtime entity identifier (EntityId)"
   id: ID!
 
-  type: License!
+  "License code defined by Joystream"
+  code: Int
 
   "Attribution (if required by the license)"
   attribution: String
 
-  happenedIn: Block!
+  "Custom license content"
+  custom_text: String
 }
 
 type FeaturedVideo @entity {