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
763548f7
Commit
763548f7
authored
Nov 05, 2020
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that we test assignability during resolve_type
This is useful for usages of loads in arguments.
parent
4dc64fe5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
app/graphql/gitlab_schema.rb
app/graphql/gitlab_schema.rb
+7
-0
app/graphql/types/base_object.rb
app/graphql/types/base_object.rb
+3
-3
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
+30
-0
No files found.
app/graphql/gitlab_schema.rb
View file @
763548f7
...
...
@@ -78,6 +78,13 @@ class GitlabSchema < GraphQL::Schema
find_by_gid
(
gid
)
end
def
resolve_type
(
type
,
object
,
ctx
=
:__undefined__
)
tc
=
type
.
metadata
[
:type_class
]
return
if
tc
.
respond_to?
(
:assignable?
)
&&
!
tc
.
assignable?
(
object
)
super
end
# Find an object by looking it up from its 'GlobalID'.
#
# * For `ApplicationRecord`s, this is equivalent to
...
...
app/graphql/types/base_object.rb
View file @
763548f7
...
...
@@ -23,12 +23,12 @@ module Types
context
[
:current_user
]
end
def
self
.
resolve_type
(
object
,
contex
t
)
def
self
.
assignable?
(
objec
t
)
assignable
=
accepts
return
self
if
assignable
.
blank?
return
true
if
assignable
.
blank?
self
if
assignable
.
any?
{
|
cls
|
object
.
is_a?
(
cls
)
}
assignable
.
any?
{
|
cls
|
object
.
is_a?
(
cls
)
}
end
end
end
ee/spec/requests/api/graphql/mutations/issues/update_spec.rb
View file @
763548f7
...
...
@@ -75,6 +75,36 @@ RSpec.describe 'Update of an existing issue' do
expect
(
graphql_errors
).
not_to
be_blank
end
end
# TODO: remove when the global-ID compatibility layer is removed,
# at which point this error becomes unreachable because the query will
# be rejected as ill-typed.
context
'the epic is not an epic, using the ID type'
do
let
(
:mutation
)
do
query
=
<<~
GQL
mutation($epic: ID!, $path: ID!, $iid: String!) {
updateIssue(input: { epicId: $epic, projectPath: $path, iid: $iid }) {
errors
}
}
GQL
::
GraphqlHelpers
::
MutationDefinition
.
new
(
query
,
{
epic:
global_id_of
(
create
(
:user
)),
iid:
issue
.
iid
.
to_s
,
path:
project
.
full_path
})
end
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
).
to
contain_exactly
(
a_hash_including
(
'message'
=>
/No object found/
)
)
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