Skip to content
代码片段 群组 项目
未验证 提交 cce43385 编辑于 作者: Lee Tickett's avatar Lee Tickett
浏览文件

Add achievement and user achievement GraphQL count

Changelog: added
上级 a0bd7593
No related branches found
No related tags found
无相关合并请求
......@@ -5,6 +5,8 @@ module Achievements
class AchievementType < BaseObject
graphql_name 'Achievement'
connection_type_class(Types::CountableConnectionType)
authorize :read_achievement
field :id,
......
......@@ -5,6 +5,8 @@ module Achievements
class UserAchievementType < BaseObject
graphql_name 'UserAchievement'
connection_type_class(Types::CountableConnectionType)
authorize :read_user_achievement
field :id,
......
......@@ -7439,6 +7439,7 @@ The connection type for [`Achievement`](#achievement).
 
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="achievementconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. |
| <a id="achievementconnectionedges"></a>`edges` | [`[AchievementEdge]`](#achievementedge) | A list of edges. |
| <a id="achievementconnectionnodes"></a>`nodes` | [`[Achievement]`](#achievement) | A list of nodes. |
| <a id="achievementconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
......@@ -11766,6 +11767,7 @@ The connection type for [`UserAchievement`](#userachievement).
 
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="userachievementconnectioncount"></a>`count` | [`Int!`](#int) | Total count of collection. |
| <a id="userachievementconnectionedges"></a>`edges` | [`[UserAchievementEdge]`](#userachievementedge) | A list of edges. |
| <a id="userachievementconnectionnodes"></a>`nodes` | [`[UserAchievement]`](#userachievement) | A list of nodes. |
| <a id="userachievementconnectionpageinfo"></a>`pageInfo` | [`PageInfo!`](#pageinfo) | Information to aid in pagination. |
......@@ -14,8 +14,10 @@
<<~HEREDOC
id
achievements {
count
nodes {
userAchievements {
count
nodes {
id
achievement {
......@@ -58,6 +60,11 @@
)
end
it 'returns the correct achievement and user_achievement counts' do
expect(graphql_data_at(:namespace, :achievements, :count)).to be(1)
expect(graphql_data_at(:namespace, :achievements, :nodes, :userAchievements, :count)).to contain_exactly(1)
end
it 'can lookahead to eliminate N+1 queries', :use_clean_rails_memory_store_caching do
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
post_graphql(query, current_user: user)
......
......@@ -13,6 +13,7 @@
let_it_be(:fields) do
<<~HEREDOC
userAchievements {
count
nodes {
id
achievement {
......@@ -54,6 +55,10 @@
)
end
it 'returns the correct user_achievement count' do
expect(graphql_data_at(:user, :userAchievements, :count)).to be(1)
end
it 'can lookahead to eliminate N+1 queries', :use_clean_rails_memory_store_caching do
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
post_graphql(query, current_user: user)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册