Commit 01fd6f35 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '34757-bugfix-graphql-missing-todo-types' into 'master'

Fix errors in GraphQL Todos API due to missing TargetTypeEnum values

See merge request gitlab-org/gitlab!19052
parents 6080bec8 a51ed1c4
......@@ -2,8 +2,10 @@
module Types
class TodoTargetEnum < BaseEnum
value 'Issue'
value 'MergeRequest'
value 'Epic'
value 'COMMIT', value: 'Commit', description: 'A Commit'
value 'ISSUE', value: 'Issue', description: 'An Issue'
value 'MERGEREQUEST', value: 'MergeRequest', description: 'A MergeRequest'
end
end
Types::TodoTargetEnum.prepend_if_ee('::EE::Types::TodoTargetEnum')
......@@ -40,7 +40,8 @@ module Types
field :body, GraphQL::STRING_TYPE,
description: 'Body of the todo',
null: false
null: false,
calls_gitaly: true # TODO This is only true when `target_type` is `Commit`. See https://gitlab.com/gitlab-org/gitlab/issues/34757#note_234752665
field :state, Types::TodoStateEnum,
description: 'State of the todo',
......
---
title: Fix errors in GraphQL Todos API due to missing TargetTypeEnum values
merge_request: 19052
author:
type: fixed
# frozen_string_literal: true
module EE
module Types
module TodoTargetEnum
extend ActiveSupport::Concern
prepended do
value 'DESIGN', value: 'DesignManagement::Design', description: 'A Design'
value 'EPIC', value: 'Epic', description: 'An Epic'
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'getting project information' do
include GraphqlHelpers
set(:current_user) { create(:user) }
set(:design_todo) { create(:todo, user: current_user, target: create(:design)) }
set(:epic_todo) { create(:todo, user: current_user, target: create(:epic)) }
let(:fields) do
<<~QUERY
nodes {
#{all_graphql_fields_for('todos'.classify)}
}
QUERY
end
let(:query) do
graphql_query_for('currentUser', {}, query_graphql_field('todos', {}, fields))
end
subject { graphql_data.dig('currentUser', 'todos', 'nodes') }
before do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
it 'returns Todos for all target types' do
is_expected.to include(
a_hash_including('targetType' => 'DESIGN'),
a_hash_including('targetType' => 'EPIC')
)
end
end
......@@ -13,7 +13,7 @@ describe 'Query current user todos' do
let(:fields) do
<<~QUERY
nodes {
id
#{all_graphql_fields_for('todos'.classify)}
}
QUERY
end
......@@ -28,6 +28,8 @@ describe 'Query current user todos' do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
it 'contains the expected ids' do
is_expected.to include(
a_hash_including('id' => commit_todo.to_global_id.to_s),
......@@ -35,4 +37,12 @@ describe 'Query current user todos' do
a_hash_including('id' => merge_request_todo.to_global_id.to_s)
)
end
it 'returns Todos for all target types' do
is_expected.to include(
a_hash_including('targetType' => 'COMMIT'),
a_hash_including('targetType' => 'ISSUE'),
a_hash_including('targetType' => 'MERGEREQUEST')
)
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'getting project information' do
include GraphqlHelpers
let(:query) do
graphql_query_for('currentUser', {}, 'name')
end
subject { graphql_data['currentUser'] }
before do
post_graphql(query, current_user: current_user)
end
context 'when there is a current_user' do
set(:current_user) { create(:user) }
it_behaves_like 'a working graphql query'
it { is_expected.to include('name' => current_user.name) }
end
context 'when there is no current_user' do
let(:current_user) { nil }
it_behaves_like 'a working graphql query'
it { is_expected.to be_nil }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment