Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bb66e5a4
Commit
bb66e5a4
authored
Feb 21, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
c0579ede
7ff0c8ae
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
209 additions
and
15 deletions
+209
-15
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+8
-0
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+24
-1
app/graphql/types/issuable_state_enum.rb
app/graphql/types/issuable_state_enum.rb
+12
-0
app/graphql/types/issue_state_enum.rb
app/graphql/types/issue_state_enum.rb
+8
-0
app/graphql/types/issue_type.rb
app/graphql/types/issue_type.rb
+1
-1
app/graphql/types/merge_request_state_enum.rb
app/graphql/types/merge_request_state_enum.rb
+10
-0
app/graphql/types/merge_request_type.rb
app/graphql/types/merge_request_type.rb
+1
-1
app/models/concerns/closed_at_filterable.rb
app/models/concerns/closed_at_filterable.rb
+14
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+1
-0
changelogs/unreleased/56492-implement-new-arguments-state-closed_before-and-closed_after-for-issuesresolver-in-graphql.yml
...before-and-closed_after-for-issuesresolver-in-graphql.yml
+5
-0
doc/api/README.md
doc/api/README.md
+1
-1
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+30
-0
spec/graphql/resolvers/issues_resolver_spec.rb
spec/graphql/resolvers/issues_resolver_spec.rb
+58
-11
spec/graphql/types/issuable_state_enum_spec.rb
spec/graphql/types/issuable_state_enum_spec.rb
+9
-0
spec/graphql/types/issue_state_enum_spec.rb
spec/graphql/types/issue_state_enum_spec.rb
+9
-0
spec/graphql/types/merge_request_state_enum_spec.rb
spec/graphql/types/merge_request_state_enum_spec.rb
+13
-0
spec/support/shared_examples/graphql/issuable_state_shared_examples.rb
...shared_examples/graphql/issuable_state_shared_examples.rb
+5
-0
No files found.
app/finders/issuable_finder.rb
View file @
bb66e5a4
...
...
@@ -94,6 +94,7 @@ class IssuableFinder
items
=
by_scope
(
items
)
items
=
by_created_at
(
items
)
items
=
by_updated_at
(
items
)
items
=
by_closed_at
(
items
)
items
=
by_state
(
items
)
items
=
by_group
(
items
)
items
=
by_assignee
(
items
)
...
...
@@ -353,6 +354,13 @@ class IssuableFinder
items
end
def
by_closed_at
(
items
)
items
=
items
.
closed_after
(
params
[
:closed_after
])
if
params
[
:closed_after
].
present?
items
=
items
.
closed_before
(
params
[
:closed_before
])
if
params
[
:closed_before
].
present?
items
end
# rubocop: disable CodeReuse/ActiveRecord
def
by_state
(
items
)
case
params
[
:state
].
to_s
...
...
app/graphql/resolvers/issues_resolver.rb
View file @
bb66e5a4
...
...
@@ -9,7 +9,30 @@ module Resolvers
argument
:iids
,
[
GraphQL
::
ID_TYPE
],
required:
false
,
description:
'The list of IIDs of issues, e.g., [1, 2]'
argument
:state
,
Types
::
IssuableStateEnum
,
required:
false
,
description:
"Current state of Issue"
argument
:label_name
,
GraphQL
::
STRING_TYPE
.
to_list_type
,
required:
false
,
description:
"Labels applied to the Issue"
argument
:created_before
,
Types
::
TimeType
,
required:
false
,
description:
"Issues created before this date"
argument
:created_after
,
Types
::
TimeType
,
required:
false
,
description:
"Issues created after this date"
argument
:updated_before
,
Types
::
TimeType
,
required:
false
,
description:
"Issues updated before this date"
argument
:updated_after
,
Types
::
TimeType
,
required:
false
,
description:
"Issues updated after this date"
argument
:closed_before
,
Types
::
TimeType
,
required:
false
,
description:
"Issues closed before this date"
argument
:closed_after
,
Types
::
TimeType
,
required:
false
,
description:
"Issues closed after this date"
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
argument
:sort
,
Types
::
Sort
,
...
...
app/graphql/types/issuable_state_enum.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
module
Types
class
IssuableStateEnum
<
BaseEnum
graphql_name
'IssuableState'
description
'State of a GitLab issue or merge request'
value
'opened'
value
'closed'
value
'locked'
end
end
app/graphql/types/issue_state_enum.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
module
Types
class
IssueStateEnum
<
IssuableStateEnum
graphql_name
'IssueState'
description
'State of a GitLab issue'
end
end
app/graphql/types/issue_type.rb
View file @
bb66e5a4
...
...
@@ -11,7 +11,7 @@ module Types
field
:iid
,
GraphQL
::
ID_TYPE
,
null:
false
field
:title
,
GraphQL
::
STRING_TYPE
,
null:
false
field
:description
,
GraphQL
::
STRING_TYPE
,
null:
true
field
:state
,
GraphQL
::
STRING_TYPE
,
null:
false
field
:state
,
IssueStateEnum
,
null:
false
field
:author
,
Types
::
UserType
,
null:
false
,
...
...
app/graphql/types/merge_request_state_enum.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
module
Types
class
MergeRequestStateEnum
<
IssuableStateEnum
graphql_name
'MergeRequestState'
description
'State of a GitLab merge request'
value
'merged'
end
end
app/graphql/types/merge_request_type.rb
View file @
bb66e5a4
...
...
@@ -12,7 +12,7 @@ module Types
field
:iid
,
GraphQL
::
ID_TYPE
,
null:
false
field
:title
,
GraphQL
::
STRING_TYPE
,
null:
false
field
:description
,
GraphQL
::
STRING_TYPE
,
null:
true
field
:state
,
GraphQL
::
STRING_TYPE
,
null:
tru
e
field
:state
,
MergeRequestStateEnum
,
null:
fals
e
field
:created_at
,
Types
::
TimeType
,
null:
false
field
:updated_at
,
Types
::
TimeType
,
null:
false
field
:source_project
,
Types
::
ProjectType
,
null:
true
...
...
app/models/concerns/closed_at_filterable.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
module
ClosedAtFilterable
extend
ActiveSupport
::
Concern
included
do
scope
:closed_before
,
->
(
date
)
{
where
(
scoped_table
[
:closed_at
].
lteq
(
date
))
}
scope
:closed_after
,
->
(
date
)
{
where
(
scoped_table
[
:closed_at
].
gteq
(
date
))
}
def
self
.
scoped_table
arel_table
.
alias
(
table_name
)
end
end
end
app/models/concerns/issuable.rb
View file @
bb66e5a4
...
...
@@ -23,6 +23,7 @@ module Issuable
include
Sortable
include
CreatedAtFilterable
include
UpdatedAtFilterable
include
ClosedAtFilterable
# This object is used to gather issuable meta data for displaying
# upvotes, downvotes, notes and closing merge requests count for issues and merge requests
...
...
changelogs/unreleased/56492-implement-new-arguments-state-closed_before-and-closed_after-for-issuesresolver-in-graphql.yml
0 → 100644
View file @
bb66e5a4
---
title
:
"
Implement
new
arguments
`state`,
`closed_before`
and
`closed_after`
for
`IssuesResolver`
in
GraphQL"
merge_request
:
24910
author
:
type
:
changed
doc/api/README.md
View file @
bb66e5a4
...
...
@@ -146,7 +146,7 @@ Endpoints are available for:
## Road to GraphQL
Going forward, we will start on moving to
[
GraphQL
](
http://graphql.org/learn/best-practices/
)
and deprecate the use of
[
GraphQL
](
graphql/index.md
)
and deprecate the use of
controller-specific endpoints. GraphQL has a number of benefits:
1.
We avoid having to maintain two different APIs.
...
...
spec/finders/issues_finder_spec.rb
View file @
bb66e5a4
...
...
@@ -462,6 +462,36 @@ describe IssuesFinder do
end
end
context
'filtering by closed_at'
do
let!
(
:closed_issue1
)
{
create
(
:issue
,
project:
project1
,
state: :closed
,
closed_at:
1
.
week
.
ago
)
}
let!
(
:closed_issue2
)
{
create
(
:issue
,
project:
project2
,
state: :closed
,
closed_at:
1
.
week
.
from_now
)
}
let!
(
:closed_issue3
)
{
create
(
:issue
,
project:
project2
,
state: :closed
,
closed_at:
2
.
weeks
.
from_now
)
}
context
'through closed_after'
do
let
(
:params
)
{
{
state: :closed
,
closed_after:
closed_issue3
.
closed_at
}
}
it
'returns issues closed on or after the given date'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue3
)
end
end
context
'through closed_before'
do
let
(
:params
)
{
{
state: :closed
,
closed_before:
closed_issue1
.
closed_at
}
}
it
'returns issues closed on or before the given date'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue1
)
end
end
context
'through closed_after and closed_before'
do
let
(
:params
)
{
{
state: :closed
,
closed_after:
closed_issue2
.
closed_at
,
closed_before:
closed_issue3
.
closed_at
}
}
it
'returns issues closed between the given dates'
do
expect
(
issues
).
to
contain_exactly
(
closed_issue2
,
closed_issue3
)
end
end
end
context
'filtering by reaction name'
do
context
'user searches by no reaction'
do
let
(
:params
)
{
{
my_reaction_emoji:
'None'
}
}
...
...
spec/graphql/resolvers/issues_resolver_spec.rb
View file @
bb66e5a4
...
...
@@ -5,16 +5,63 @@ describe Resolvers::IssuesResolver do
let
(
:current_user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
(
:project
)
}
set
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
set
(
:issue2
)
{
create
(
:issue
,
project:
project
,
title:
'foo'
)
}
set
(
:issue1
)
{
create
(
:issue
,
project:
project
,
state: :opened
,
created_at:
3
.
hours
.
ago
,
updated_at:
3
.
hours
.
ago
)
}
set
(
:issue2
)
{
create
(
:issue
,
project:
project
,
state: :closed
,
title:
'foo'
,
created_at:
1
.
hour
.
ago
,
updated_at:
1
.
hour
.
ago
,
closed_at:
1
.
hour
.
ago
)
}
set
(
:label1
)
{
create
(
:label
,
project:
project
)
}
set
(
:label2
)
{
create
(
:label
,
project:
project
)
}
before
do
project
.
add_developer
(
current_user
)
create
(
:label_link
,
label:
label1
,
target:
issue1
)
create
(
:label_link
,
label:
label1
,
target:
issue2
)
create
(
:label_link
,
label:
label2
,
target:
issue2
)
end
describe
'#resolve'
do
it
'finds all issues'
do
expect
(
resolve_issues
).
to
contain_exactly
(
issue
,
issue2
)
expect
(
resolve_issues
).
to
contain_exactly
(
issue1
,
issue2
)
end
it
'filters by state'
do
expect
(
resolve_issues
(
state:
'opened'
)).
to
contain_exactly
(
issue1
)
expect
(
resolve_issues
(
state:
'closed'
)).
to
contain_exactly
(
issue2
)
end
it
'filters by labels'
do
expect
(
resolve_issues
(
label_name:
[
label1
.
title
])).
to
contain_exactly
(
issue1
,
issue2
)
expect
(
resolve_issues
(
label_name:
[
label1
.
title
,
label2
.
title
])).
to
contain_exactly
(
issue2
)
end
describe
'filters by created_at'
do
it
'filters by created_before'
do
expect
(
resolve_issues
(
created_before:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue1
)
end
it
'filters by created_after'
do
expect
(
resolve_issues
(
created_after:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue2
)
end
end
describe
'filters by updated_at'
do
it
'filters by updated_before'
do
expect
(
resolve_issues
(
updated_before:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue1
)
end
it
'filters by updated_after'
do
expect
(
resolve_issues
(
updated_after:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue2
)
end
end
describe
'filters by closed_at'
do
let!
(
:issue3
)
{
create
(
:issue
,
project:
project
,
state: :closed
,
closed_at:
3
.
hours
.
ago
)
}
it
'filters by closed_before'
do
expect
(
resolve_issues
(
closed_before:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue3
)
end
it
'filters by closed_after'
do
expect
(
resolve_issues
(
closed_after:
2
.
hours
.
ago
)).
to
contain_exactly
(
issue2
)
end
end
it
'searches issues'
do
...
...
@@ -22,7 +69,7 @@ describe Resolvers::IssuesResolver do
end
it
'sort issues'
do
expect
(
resolve_issues
(
sort:
'created_desc'
)).
to
eq
[
issue2
,
issue
]
expect
(
resolve_issues
(
sort:
'created_desc'
)).
to
eq
[
issue2
,
issue
1
]
end
it
'returns issues user can see'
do
...
...
@@ -30,31 +77,31 @@ describe Resolvers::IssuesResolver do
create
(
:issue
,
confidential:
true
)
expect
(
resolve_issues
).
to
contain_exactly
(
issue
,
issue2
)
expect
(
resolve_issues
).
to
contain_exactly
(
issue
1
,
issue2
)
end
it
'finds a specific issue with iid'
do
expect
(
resolve_issues
(
iid:
issue
.
iid
)).
to
contain_exactly
(
issue
)
expect
(
resolve_issues
(
iid:
issue
1
.
iid
)).
to
contain_exactly
(
issue1
)
end
it
'finds a specific issue with iids'
do
expect
(
resolve_issues
(
iids:
issue
.
iid
)).
to
contain_exactly
(
issue
)
expect
(
resolve_issues
(
iids:
issue
1
.
iid
)).
to
contain_exactly
(
issue1
)
end
it
'finds multiple issues with iids'
do
expect
(
resolve_issues
(
iids:
[
issue
.
iid
,
issue2
.
iid
]))
.
to
contain_exactly
(
issue
,
issue2
)
expect
(
resolve_issues
(
iids:
[
issue
1
.
iid
,
issue2
.
iid
]))
.
to
contain_exactly
(
issue
1
,
issue2
)
end
it
'finds only the issues within the project we are looking at'
do
another_project
=
create
(
:project
)
iids
=
[
issue
,
issue2
].
map
(
&
:iid
)
iids
=
[
issue
1
,
issue2
].
map
(
&
:iid
)
iids
.
each
do
|
iid
|
create
(
:issue
,
project:
another_project
,
iid:
iid
)
end
expect
(
resolve_issues
(
iids:
iids
)).
to
contain_exactly
(
issue
,
issue2
)
expect
(
resolve_issues
(
iids:
iids
)).
to
contain_exactly
(
issue
1
,
issue2
)
end
end
...
...
spec/graphql/types/issuable_state_enum_spec.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
require
'spec_helper'
describe
GitlabSchema
.
types
[
'IssuableState'
]
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'IssuableState'
)
}
it_behaves_like
'issuable state'
end
spec/graphql/types/issue_state_enum_spec.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
require
'spec_helper'
describe
GitlabSchema
.
types
[
'IssueState'
]
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'IssueState'
)
}
it_behaves_like
'issuable state'
end
spec/graphql/types/merge_request_state_enum_spec.rb
0 → 100644
View file @
bb66e5a4
# frozen_string_literal: true
require
'spec_helper'
describe
GitlabSchema
.
types
[
'MergeRequestState'
]
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'MergeRequestState'
)
}
it_behaves_like
'issuable state'
it
'exposes all the existing merge request states'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
'merged'
)
end
end
spec/support/shared_examples/graphql/issuable_state_shared_examples.rb
0 → 100644
View file @
bb66e5a4
RSpec
.
shared_examples
'issuable state'
do
it
'exposes all the existing issuable states'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[opened closed locked]
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment