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
e86a2e7e
Commit
e86a2e7e
authored
Apr 05, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase GraphQL complexity
An IntrospectionQuery required more complexity points.
parent
425377f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
8 deletions
+109
-8
app/graphql/gitlab_schema.rb
app/graphql/gitlab_schema.rb
+4
-5
spec/fixtures/api/graphql/introspection.graphql
spec/fixtures/api/graphql/introspection.graphql
+92
-0
spec/requests/api/graphql/gitlab_schema_spec.rb
spec/requests/api/graphql/gitlab_schema_spec.rb
+13
-3
No files found.
app/graphql/gitlab_schema.rb
View file @
e86a2e7e
# frozen_string_literal: true
# frozen_string_literal: true
class
GitlabSchema
<
GraphQL
::
Schema
class
GitlabSchema
<
GraphQL
::
Schema
# Took our current most complicated query in use, issues.graphql,
# Currently an IntrospectionQuery has a complexity of 179.
# with a complexity of 19, and added a 20 point buffer to it.
# These values will evolve over time.
# These values will evolve over time.
DEFAULT_MAX_COMPLEXITY
=
4
0
DEFAULT_MAX_COMPLEXITY
=
20
0
AUTHENTICATED_COMPLEXITY
=
50
AUTHENTICATED_COMPLEXITY
=
2
50
ADMIN_COMPLEXITY
=
6
0
ADMIN_COMPLEXITY
=
30
0
use
BatchLoader
::
GraphQL
use
BatchLoader
::
GraphQL
use
Gitlab
::
Graphql
::
Authorize
use
Gitlab
::
Graphql
::
Authorize
...
...
spec/fixtures/api/graphql/introspection.graphql
0 → 100644
View file @
e86a2e7e
# pulled from GraphiQL query
query
IntrospectionQuery
{
__schema
{
queryType
{
name
}
mutationType
{
name
}
subscriptionType
{
name
}
types
{
...
FullType
}
directives
{
name
description
locations
args
{
...
InputValue
}
}
}
}
fragment
FullType
on
__Type
{
kind
name
description
fields
(
includeDeprecated
:
true
)
{
name
description
args
{
...
InputValue
}
type
{
...
TypeRef
}
isDeprecated
deprecationReason
}
inputFields
{
...
InputValue
}
interfaces
{
...
TypeRef
}
enumValues
(
includeDeprecated
:
true
)
{
name
description
isDeprecated
deprecationReason
}
possibleTypes
{
...
TypeRef
}
}
fragment
InputValue
on
__InputValue
{
name
description
type
{
...
TypeRef
}
defaultValue
}
fragment
TypeRef
on
__Type
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
ofType
{
kind
name
}
}
}
}
}
}
}
}
spec/requests/api/graphql/gitlab_schema_spec.rb
View file @
e86a2e7e
...
@@ -3,14 +3,24 @@ require 'spec_helper'
...
@@ -3,14 +3,24 @@ require 'spec_helper'
describe
'GitlabSchema configurations'
do
describe
'GitlabSchema configurations'
do
include
GraphqlHelpers
include
GraphqlHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
it
'shows an error if complexity is too high'
do
let!
(
:query
)
{
graphql_query_for
(
'project'
,
'fullPath'
=>
project
.
full_path
)
}
project
=
create
(
:project
,
:repository
)
query
=
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
"id
\n
name
\n
description"
)
it
'shows an error if complexity it too high'
do
allow
(
GitlabSchema
).
to
receive
(
:max_query_complexity
).
and_return
1
allow
(
GitlabSchema
).
to
receive
(
:max_query_complexity
).
and_return
1
post_graphql
(
query
,
current_user:
nil
)
post_graphql
(
query
,
current_user:
nil
)
expect
(
graphql_errors
.
first
[
'message'
]).
to
include
(
'which exceeds max complexity of 1'
)
expect
(
graphql_errors
.
first
[
'message'
]).
to
include
(
'which exceeds max complexity of 1'
)
end
end
context
'when IntrospectionQuery'
do
it
'is not too complex'
do
query
=
File
.
read
(
Rails
.
root
.
join
(
'spec/fixtures/api/graphql/introspection.graphql'
))
post_graphql
(
query
,
current_user:
nil
)
expect
(
graphql_errors
).
to
be_nil
end
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