diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-05-06 21:24:19 +0000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-05-06 21:24:19 +0000 |
commit | 5ee7884d91c4513e1b7322a4ca30a2c908e931b8 (patch) | |
tree | 105fad94e4647ee63cda729192f7fff7e3f0b396 /app/graphql/resolvers/concerns/resolves_pipelines.rb | |
parent | 863f2bcfb6ef7c6d3ce5726fa1a602e12f05ef57 (diff) | |
download | gitlab-ce-5ee7884d91c4513e1b7322a4ca30a2c908e931b8.tar.gz |
GraphQL - Add extra complexity for resolvers
If a field is a resolver, its complexity is automatically
increased. By default we add extra points for sort and search
arguments (which will be common for various resolvers).
For specific resolvers we add field-specific complexity, e.g.
for Issues complexity is increased if we filter issues by `labelName`
(because then SQL query is more complex). We may want to tune these
values in future depending on real-life results.
Complexity is also dependent on the number of loaded nodes, but only
if we don't search by specific ID(s). Also added complexity is limited
(by default only twice more than child complexity) - the reason is
that although it's more complex to process more items, the complexity
increase is not linear (there is not so much difference between loading
10, 20 or 100 records from DB).
Diffstat (limited to 'app/graphql/resolvers/concerns/resolves_pipelines.rb')
-rw-r--r-- | app/graphql/resolvers/concerns/resolves_pipelines.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/graphql/resolvers/concerns/resolves_pipelines.rb b/app/graphql/resolvers/concerns/resolves_pipelines.rb index 8fd26d85994..a166211fc18 100644 --- a/app/graphql/resolvers/concerns/resolves_pipelines.rb +++ b/app/graphql/resolvers/concerns/resolves_pipelines.rb @@ -19,6 +19,16 @@ module ResolvesPipelines description: "Filter pipelines by the sha of the commit they are run for" end + class_methods do + def resolver_complexity(args) + complexity = super + complexity += 2 if args[:sha] + complexity += 2 if args[:ref] + + complexity + end + end + def resolve_pipelines(project, params = {}) PipelinesFinder.new(project, context[:current_user], params).execute end |