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
1285b005
Commit
1285b005
authored
May 31, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added common fields to the IssueType
and allow passing of child_complexity to the 'resolver_complexity' metho
parent
b9798c15
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
6 deletions
+62
-6
app/graphql/resolvers/base_resolver.rb
app/graphql/resolvers/base_resolver.rb
+1
-1
app/graphql/resolvers/concerns/resolves_pipelines.rb
app/graphql/resolvers/concerns/resolves_pipelines.rb
+1
-1
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+1
-1
app/graphql/types/base_field.rb
app/graphql/types/base_field.rb
+1
-1
app/graphql/types/issue_type.rb
app/graphql/types/issue_type.rb
+6
-0
app/presenters/issue_presenter.rb
app/presenters/issue_presenter.rb
+11
-1
changelogs/unreleased/10795-add-epic-tree-BE-CE-epic-graphql-support.yml
...leased/10795-add-epic-tree-BE-CE-epic-graphql-support.yml
+5
-0
spec/graphql/types/base_field_spec.rb
spec/graphql/types/base_field_spec.rb
+1
-1
spec/graphql/types/issue_type_spec.rb
spec/graphql/types/issue_type_spec.rb
+6
-0
spec/presenters/issue_presenter_spec.rb
spec/presenters/issue_presenter_spec.rb
+29
-0
No files found.
app/graphql/resolvers/base_resolver.rb
View file @
1285b005
...
...
@@ -10,7 +10,7 @@ module Resolvers
end
end
def
self
.
resolver_complexity
(
args
)
def
self
.
resolver_complexity
(
args
,
child_complexity
:
)
complexity
=
1
complexity
+=
1
if
args
[
:sort
]
complexity
+=
5
if
args
[
:search
]
...
...
app/graphql/resolvers/concerns/resolves_pipelines.rb
View file @
1285b005
...
...
@@ -20,7 +20,7 @@ module ResolvesPipelines
end
class_methods
do
def
resolver_complexity
(
args
)
def
resolver_complexity
(
args
,
child_complexity
:
)
complexity
=
super
complexity
+=
2
if
args
[
:sha
]
complexity
+=
2
if
args
[
:ref
]
...
...
app/graphql/resolvers/issues_resolver.rb
View file @
1285b005
...
...
@@ -58,7 +58,7 @@ module Resolvers
IssuesFinder
.
new
(
context
[
:current_user
],
args
).
execute
end
def
self
.
resolver_complexity
(
args
)
def
self
.
resolver_complexity
(
args
,
child_complexity
:
)
complexity
=
super
complexity
+=
2
if
args
[
:labelName
]
...
...
app/graphql/types/base_field.rb
View file @
1285b005
...
...
@@ -33,7 +33,7 @@ module Types
limit_value
=
[
args
[
:first
],
args
[
:last
],
page_size
].
compact
.
min
# Resolvers may add extra complexity depending on used arguments
complexity
=
child_complexity
+
self
.
resolver
&
.
try
(
:resolver_complexity
,
args
).
to_i
complexity
=
child_complexity
+
self
.
resolver
&
.
try
(
:resolver_complexity
,
args
,
child_complexity:
child_complexity
).
to_i
# Resolvers may add extra complexity depending on number of items being loaded.
multiplier
=
self
.
resolver
&
.
try
(
:complexity_multiplier
,
args
).
to_f
...
...
app/graphql/types/issue_type.rb
View file @
1285b005
...
...
@@ -15,6 +15,10 @@ module Types
field
:description
,
GraphQL
::
STRING_TYPE
,
null:
true
field
:state
,
IssueStateEnum
,
null:
false
field
:reference
,
GraphQL
::
STRING_TYPE
,
null:
false
,
method: :to_reference
do
argument
:full
,
GraphQL
::
BOOLEAN_TYPE
,
required:
false
,
default_value:
false
end
field
:author
,
Types
::
UserType
,
null:
false
,
resolve:
->
(
obj
,
_args
,
_ctx
)
{
Gitlab
::
Graphql
::
Loaders
::
BatchModelLoader
.
new
(
User
,
obj
.
author_id
).
find
}
...
...
@@ -37,7 +41,9 @@ module Types
field
:upvotes
,
GraphQL
::
INT_TYPE
,
null:
false
field
:downvotes
,
GraphQL
::
INT_TYPE
,
null:
false
field
:user_notes_count
,
GraphQL
::
INT_TYPE
,
null:
false
field
:web_path
,
GraphQL
::
STRING_TYPE
,
null:
false
,
method: :issue_path
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
false
field
:relative_position
,
GraphQL
::
INT_TYPE
,
null:
true
field
:closed_at
,
Types
::
TimeType
,
null:
true
...
...
app/presenters/issue_presenter.rb
View file @
1285b005
...
...
@@ -4,6 +4,16 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated
presents
:issue
def
web_url
Gitlab
::
UrlBuilder
.
build
(
issue
)
url_builder
.
url
end
def
issue_path
url_builder
.
issue_path
(
issue
)
end
private
def
url_builder
@url_builder
||=
Gitlab
::
UrlBuilder
.
new
(
issue
)
end
end
changelogs/unreleased/10795-add-epic-tree-BE-CE-epic-graphql-support.yml
0 → 100644
View file @
1285b005
---
title
:
Added reference, web_path, and relative_position fields to GraphQL Issue
merge_request
:
28998
author
:
type
:
changed
spec/graphql/types/base_field_spec.rb
View file @
1285b005
...
...
@@ -6,7 +6,7 @@ describe Types::BaseField do
context
'when considering complexity'
do
let
(
:resolver
)
do
Class
.
new
(
described_class
)
do
def
self
.
resolver_complexity
(
args
)
def
self
.
resolver_complexity
(
args
,
child_complexity
:
)
2
if
args
[
:foo
]
end
...
...
spec/graphql/types/issue_type_spec.rb
View file @
1285b005
...
...
@@ -6,4 +6,10 @@ describe GitlabSchema.types['Issue'] do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'Issue'
)
}
it
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:read_issue
)
}
it
'has specific fields'
do
%i[relative_position web_path web_url reference]
.
each
do
|
field_name
|
expect
(
described_class
).
to
have_graphql_field
(
field_name
)
end
end
end
spec/presenters/issue_presenter_spec.rb
0 → 100644
View file @
1285b005
# frozen_string_literal: true
require
'spec_helper'
describe
IssuePresenter
do
include
Gitlab
::
Routing
.
url_helpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:presenter
)
{
described_class
.
new
(
issue
,
current_user:
user
)
}
before
do
group
.
add_developer
(
user
)
end
describe
'#web_url'
do
it
'returns correct path'
do
expect
(
presenter
.
web_url
).
to
eq
"http://localhost/
#{
group
.
name
}
/
#{
project
.
name
}
/issues/
#{
issue
.
iid
}
"
end
end
describe
'#issue_path'
do
it
'returns correct path'
do
expect
(
presenter
.
issue_path
).
to
eq
"/
#{
group
.
name
}
/
#{
project
.
name
}
/issues/
#{
issue
.
iid
}
"
end
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