Orion v2 is a major architecture change compared to Orion v1:
- No proxying to external Query Node: Event processing is now part of Orion, the state is unified in a single database (PostgreSQL) instead of being spread between Joystream Query Node and Orion.
- Subsquid framework is now used for event processing and GraphQL api generation.
For detailed overview of the new architecture, see the developer guide
- Significantly improved query speed should be observed in most cases (the average query should be 2x faster in Orion v2, see the latest benchmarking results)
- Generally reduced set of supported queries and queryable entity fields. Only queries for the entities based on
members
,content
andstorage
Joystream modules, which are relevant to Atlas, are now supported by Orion. Additionally, fields likeownerCuratorGroup
, channel'scollaborators
etc., which are not yet supported by Atlas are also not yet supported in Orion v2. Event
interface has been replaced withEventData
union, as GraphQL interfaces are not supported in Subsquid. This affects the wayevents
query works, as well as removes specific event queries (likecategoryCreatedEvents
,videoReactedEvents
etc.)- Some redundant relationships were removed (for example, entities that had relation to both
Video
and video'sChannel
, now may only have relation to aVideo
. Similarly, entities that containedownerMember
/ownerCuratorGroup
fields, but also had a relation toChannel
, no longer include redundant channel ownership information), which were previously required to workaround lack of deeply nested filtering. For the same reason, other relations were replaced with more specific ones (for exmapleauction
instead ofvideo
). Some examples of this include:- Auction bid canceled event has a relation to
bid
instead ofvideo
, - Auction bid made event no longer has
bidAmount
,previousTopBid
andpreviousTopBidder
. They can all be derived from the relatedbid
instead, - Auction canceled event has a relation to
auction
instead ofvideo
, - Event with
winningBid
field no longer contian relations likevideo
orwinner
, as they can be derived fromwinningBid
, - Most of other nft-related events now have a relation to
nft
instead ofvideo
.
- Auction bid canceled event has a relation to
- NFT's
transactionalStatus
andtransactionalStatusAuction
is now represented as a singletransactionalStatus
which includesTransactionalStatusAuction
as one of the variants. - Entity fields like
nftOwnerMember
,isNftOwnerChannel
,nftOwnerCuratorGroup
have been relaplaced with a singleNftOwner
union. Channel.followsNum
,Channel.videoViewsNum
andVideo.viewsNum
fields have been added and can now be used for filtering, sorting etc. (in Orion v1 fields likeChannel.follows
,Channel.views
andVideo.views
also existed, but had limited functionality)- Some small differences in the representation of empty values:
Auction.buyNowPrice
:0
=>null
Comment.reactionsCountByReactionId
:[]
=>null
DistributionBucketFamilyMetadata.areas
:[]
=>null
VideoCategory.description
:''
=>null
- Some small differences in types:
StorageBag.owner.channelId
:number
=>string
DistributionBucketFamilyMetadata.areas
is now ajsonb
field, so it was possible to skip one level of nesting:DistributionBucketFamilyMetadata.areas.area
=>DistributionBucketFamilyMetadata.areas
- Some fileds were renamed:
Event.createdAt
=>Event.timestamp
*Event.contentActor
=>*EventData.actor
NftBoughtEvent.member
=>NftBoughtEventData.buyer
Membership.memberBannedFromChannels
=>Membership.bannedFromChannels
- Some entity ids are not backward-compatible:
DistributionBucketFamilyMetadata
StorageBucketOperatorMetadata
DistributionBucketOperatorMetadata
MemberMetadata
Event
- Some entities no longer have ids, as are now stored as
jsonb
objects in the parent table:GeoCoordinates
NodeLocationMetadata
DistributionBucketFamilyGeographicArea
CommentReactionsCountByReactionId
VideoReactionsCountByReactionType
- In Orion v1 providing a non-existing category id resulted in a creation of empty video category (without any
name
ordescription
). Such categories are no longer created, providing non-existing category as part ofContentMetadata
results in settingVideo.category
tonull
instead. Channel.activeVideoCounter
andVideoCategory.activeVideoCounter
fields have been removed, instead customextendedChannels
andextendedVideoCategories
queries have been introduced, which allow retrieving the number of active videos per channel/category.createdAt
andupdatedAt
fields are no longer automatically added to entities in Subsquid, so most of the entities no longer include them (unless they were explicitly required by Atlas).Many-to-Many
entity relationships are not supported in Subsquid, so those relationships were refactored to 2-side Many-to-One relationships with a specific "join entity". This means that some queries may now require one more level of nesting, ie.:Channel.bannedMembers.id
=>Channel.bannedMembers.member.id
Auction.whitelistedMembers.id
=>Auction.whitelistedMembers.member.id
Membership.whitelistedInAuctions.id
=>Membership.whitelistedInAuctions.auction.id
StorageBucket.bags.id
=>StorageBucket.bags.bag.id
DistributionBucket.bags.id
=>DistributionBucket.bags.bag.id
StorageBag.storageBuckets.id
=>StorageBag.storageBuckets.storageBucket.id
StorageBag.distributionBuckets.id
=>StorageBag.distributionBuckets.distributionBucket.id
Language
entity has been removed. Language is now represented as a simple ISO codestring
.DataTime
format is slightly different:2022-01-01T00:00:00.000Z
=>2022-01-01T00:00:00.000000Z
{ entity { relatedEntityId } }
syntax is not supported in Subsquid,{ entity { relatedEntity { id } } }
has to be used instead- the type of entity
id
property is nowString
(previouslyID
) entityByUniqueInput
queries are no longer supported. The newentityById
queries can be used instead in some cases.admin
query (kill switch) was renamed togetKillSwitch
categoryFeaturedVideos
andallCategoriesFeaturedVideos
queries do not exist anymore. Instead, videos featured in a category can be accessed throughcategory.featuredVideos
relationmostViewedCategories
andmostViewedCategoriesAllTime
queries have been removed (currently unused by Atalas)discoverChannels
andpromisingChannels
queries has been removed in favor of a new more generic/reusablemostRecentChannels
query (searching among X most recent channels)popularChannels
query has been removed, as the same results can now be obtained withchannels
/extendedChannels
query withorderBy: videoViewsNum_DESC, limit: 15
top10Channels
query has been removed as the same results can now be obtained withchannels
/extendedChannels
query withorderBy: followsNum_DESC, limit: 10
mostViewedChannelsConnection
andmostFollowedChannelsConnection
queries have been removed (currently unused by Atalas)top10VideosThisWeek
andtop10VideosThisMonth
queries have been removed, as the same results can now be obtained withmostViewedVideosConnection(limit: 10, where: $where, periodDays: (7|30), orderBy: createdAt_DESC)
querysearch
query is temporarily not supported (unused by Atals)channelNftCollectors
query now takeschannelId: String!
input instead ofwhere: ChannelNftCollectorsWhereInput
.orderBy
variants have been reduced toamount_ASC
andamount_DESC
ChannelFundsWithdrawnEventData.account
as well asChannelRewardClaimedAndWithdrawnEventData.account
are nownull
in case the funds destination wasCouncil
and account address otherwise (periously this field contained a json string representing the serializedChannelFundsDestination
enum)- Event ids are now assigned sequentially (
00000001
,00000002
,00000003
etc.) instead of being{blockNumber}-{indexInBlock}
. Because all events now live in the same database table,{blockNumber}-{indexInBlock}
would no longer be a unique identifier when dealing with metaprotocol events (as there can be multiple metaprotocol events triggered by the same runtime event) MetaprotocolTransactionStatus
has been renamed toMetaprotocolTransactionResult
and now also includes variants that have been previously represented by optional fields ofMetaprotocolTransactionSuccessful
(MetaprotocolTransactionResultCommentCreated
,MetaprotocolTransactionResultCommentEdited
etc.). To check if the transaction was generally successful you can now useevent.result.isTypeOf !== 'MetaprotocolTransactionResultFailed'
MetaprotocolTransactionErrored
variant has been replaced withMetaprotocolTransactionResultFailed
and may include slightly different error messages. The error messages should be completely removed and replaced with error codes in the future.- The default limit for number of returned rows when no limit was provided in Orion v1 was
50
. In Orion v2 there is no default limit(!)
- (Subsquid) Deeply nested filtering (for example:
videos(where: { channel: { avatarPhoto: { storageBag: { storageBuckets_some: { id_eq: "1" } } } } })
) is now supported, as well as nested field queries - (Subsquid) There are a few new properties for
where
inputs of queries, likefiled_isNull
,field_containsInsensitive
,field_not_(eq|in|contains|containsInsensitive|endsWith|startsWith)
- It is now possible to query the
resolvedUrls
property of anyStorageDataObject
(for example:{ videoById(id: "1") { media { resolvedUrls } } }
). The Orion v2 GraphQL server will then resolve it to a list of available asset urls, based on its internal distributor nodes data cache. If you providex-client-loc
header, Orion v2 will additionally prioritize distributor nodes closest to the provided location when resolving the url. The value forx-client-loc
should be provided inlat,lon
format, wherelat
is thelatitude
(-90, 90) andlon
is thelongitude
(-180, 180), for example:x-client-loc: 42.557127,-103.886719
. You can also providex-asset-urls-limit
to specify the maximum number of urls to return per asset (by default all available urls will be returned). - Censored channels and videos belonging to censored channels, as well as channels/videos excluded by the gateway operator via
excludeContent
mutation are now filtered-out from all query results by default. The same applies to videos belonging to categories not supported by the gateway (see:setSupportedCategories
operator mutation and operator queries for more details) - Video comments can also be excluded by the gateway operator via
excludeContent
mutation, but they are not filtered out from the query results in that case. Instead, theirtext
is hidden and they can be identified by havingisExcluded
property set totrue
. - Entities like
VideoViewEvent
,Report
andChannelFollow
are now part of the Subsquid GraphQL input schema / PostgreSQL database schema. In Orion v1 similar entities were stored in a local MongoDB database and some of them were exposed for the gateway operator via authorized queries likereportedChannels
,reportedVideos
. In Orion v2 the api includes autogenerated queries likevideoViewEvents
,videoViewEventsConnection
,reports
,reportsConnection
,channelFollows
,channelFollowsConnection
etc. with all the features provided by Subsquid's Openreader. However, just like in Orion v1, this data is also hidden from the public view as it includes sensitive information like IP addresses of the users. Only the Gateway operator is able to query this hidden data (see operator queries for more details). VideoHero
entity includes additional fields (video
,activatedAt
)- Featured nfts:
OwnedNft
s now haveisFeatured
property can be set by the Gateway operator.
getVideoViewPerIpTimeLimit
: allows retrieving the current value ofVideoViewPerIpTimeLimit
config value (see also:setVideoViewPerIpTimeLimit
under operator mutations)- In order to optimize Atlas queries that do complex filtering of
Event
entities, likeGetNotifications
,GetNftHistory
andGetNftActivities
, a few new entities were introduced which include a reltionship toEvent
(this was not possible in Orion v1, as there wasn't a singleEvent
entity). The new entities (and associated queries) are:Notification
(notifications
,notificationsConnection
),NftHistoryEntry
(nftHistoryEntries
,nftHistoryEntriesConnection
) andNftActivity
(nftActivities
,nftActivitiesConnection
). - historical
VideoHero
snapshots can now be queried using new autogenerated queries likevideoHeros
,videoHeroById
etc.
Auction.topBid
can no longer be a canceled bid (this was previously possible inOpenAuction
). In case the top bid gets canceled, the next best bid is set asAuction.topBid
. In case there is no next best bid,Auction.topBid
is set tonull
.- In Orion v1 (Query Node), when a member placed a bid in
OpenAuction
, it was possible for their bid in an old, already finalized auction for the same nft to get canceled (even if it was already a winning bid). Now this will no longer happen. Video.pinnedComment
relation was incorrectly declared in Orion v1 (Query Node) input schema, which resulted in some comments, which were never actually pinned, being returned asVideo.pinnedComment
. This should no longer happen in Orion v2.- In Orion v1 (Query Node) sometimes the
createdAt
field of an entity (likeMemberships
) would be incorrectly modified on update. This will no longer happen in Orion v2, as fields likecreatedAt
need to be added explicitly in Subsquid and are no longer automatically managed. - Using property aliases was not working in Orion v1 (for example:
channels { channelId: id }
), this is no longer an issue in Orion v2. OwnedNft.creatorRoyalty
was incorrectly calculated in Orion v1 (rounded down to nearest integer), this has been fixed in Orion v2, so that nowcreatorRoyalty
can have non-integer value (like0.5
).
- An authorized operator, who provided a valid
x-operator-secret
HTTP header, can see any entities hidden from the public view in the query results (unless explicitly filtered out by the querywhere
conditions or otherwise). Those include:- Censored (by the DAO) channels & videos and their related entities (nfts, auctions, comments, reactions, metadata entities etc.),
- Excluded (censored by the Gateway) channels, videos and their related entities (nfts, auctions, reactions, metadata entities etc.),
- Any content not belonging to a category currently supported by the Gateway,
- Other entities hidden from public view for security reasons:
VideoViewEvent
s,Report
s,ChannelFollow
s,NftFeaturingRequest
s.
stateSubscription
has been renamed toprocessorState
, properties have been reduced to justlastProcessedBlock
addVideoView
:- no longer requires
channelId
andcategoryId
as input - now only increases number of video views if the request is a unique request per ip-videoId pair in the last
Config.VideoViewPerIpTimeLimit
seconds (to prevent abuse). This limit can be set via environment variable or throughsetVideoViewPerIpTimeLimit
operator mutation. added
boolean was added to mutation result to indicate whether a new view was added or not
- no longer requires
followChannel
:- channel id is now returned in
channelId
field of the mutation result, instead ofid
cancelToken
is now returned as part of the mutation result. This token has to be used when unfollowing the channel to prevent arbitrarly triggeringunfollow
when there is not matching channel follow on the client side.- only one follow is now counted per client ip to prevent abuse.
added
boolean was added to mutation result to indicate whether a new follow was added or not (depending on whether a matching follow already existed for given ip-channleId pair)
- channel id is now returned in
unfollowChannel
- now additionally requires
token
as input (seefollowChannel
changes) removed
boolean was added to mutation result to indicate whether the follow was removed or not (it is only removed if there is a matching follow per token-channelId pair)
- now additionally requires
reportChannel
/reportVideo
:- now only one report can be sent from given ip for given channel/video to prevent abuse.
created
boolean was added to mutation result to indicate whether a new report was created
requestNftFeatured
- allows users to make a request for a given nft to be featured by the Gateway. Operator can then read those requests using the new queries likenftFeaturingRequests
. Functionally this feature is similar toreportChannel
/reportVideo
.
- All operator mutations now require
x-operator-secret
HTTP header to be provided, with value equal toOPERATOR_SECRET
environment value. There is currently no distinction between secret used for content featuring and other operator activities. setVideoHero
- the history of video heros' set is now persisted in the database and is publicly accessible,
- mutation result now only includes the id of the created
VideoHero
entity
setCategoryFeaturedVideos
- the mutation result now only includes
categoryId
and number of featured videos set / unset
- the mutation result now only includes
setSupportedCategories
- allows specifying which video categories are supported by the gateway. Content that doesn't belong to supported categories will not be displayed in query results. This includes the categories themselves, videos, nfts, auctions, comments, reactions etc.setVideoViewPerIpTimeLimit
- allows specifying the time after which a video view triggered from the same ip address will be counted again (see:addVideoView
)excludeContent
- allows excluding specified channels/videos/comments from all query results. Can be used as a gateway-level mechanism to censor some of the content. Comments are the only entities that don't get completely filtered-out from query results when excluded. Instead, theirtext
becomes hidden andisExcluded
property is set totrue
.restoreContent
- effectively the opposite ofexcludeContent
, can be used to make content appear in the query results again (if previously excluded).setFeaturedNfts
- allows the operator to provide the list of nfts (ids) that are currently featured by the Gateway. This will affect theisFeatured
propety of theOwnedNft
entity.