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
4dc64fe5
Commit
4dc64fe5
authored
Nov 03, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a default implementation of resolve_type
This makes use of loads a bit safer.
parent
6d32c609
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
2 deletions
+27
-2
app/graphql/types/base_object.rb
app/graphql/types/base_object.rb
+14
-0
app/graphql/types/board_type.rb
app/graphql/types/board_type.rb
+1
-1
ee/app/graphql/types/epic_type.rb
ee/app/graphql/types/epic_type.rb
+1
-1
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
+11
-0
No files found.
app/graphql/types/base_object.rb
View file @
4dc64fe5
...
...
@@ -8,6 +8,12 @@ module Types
field_class
Types
::
BaseField
def
self
.
accepts
(
*
types
)
@accepts
||=
[]
@accepts
+=
types
@accepts
end
# All graphql fields exposing an id, should expose a global id.
def
id
GitlabSchema
.
id_from_object
(
object
)
...
...
@@ -16,5 +22,13 @@ module Types
def
current_user
context
[
:current_user
]
end
def
self
.
resolve_type
(
object
,
context
)
assignable
=
accepts
return
self
if
assignable
.
blank?
self
if
assignable
.
any?
{
|
cls
|
object
.
is_a?
(
cls
)
}
end
end
end
app/graphql/types/board_type.rb
View file @
4dc64fe5
...
...
@@ -4,7 +4,7 @@ module Types
class
BoardType
<
BaseObject
graphql_name
'Board'
description
'Represents a project or group board'
accepts
::
Board
authorize
:read_board
field
:id
,
type:
GraphQL
::
ID_TYPE
,
null:
false
,
...
...
ee/app/graphql/types/epic_type.rb
View file @
4dc64fe5
...
...
@@ -6,7 +6,7 @@ module Types
graphql_name
'Epic'
description
'Represents an epic'
accepts
::
Epic
authorize
:read_epic
expose_permissions
Types
::
PermissionTypes
::
Epic
...
...
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
View file @
4dc64fe5
...
...
@@ -64,6 +64,17 @@ RSpec.describe 'Update of an existing issue' do
expect
(
graphql_errors
).
not_to
be_blank
end
end
context
'the epic is not an epic'
do
let
(
:epic
)
{
create
(
:user
)
}
it
'does not set the epic'
do
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
graphql_errors
).
not_to
be_blank
end
end
end
context
'removing epic'
do
...
...
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