diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 03:07:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 03:07:56 +0300 |
commit | 6fbaac1974d2e9a0e5296a9da2d99f356a684f91 (patch) | |
tree | 965884691ca08bf2c2a00e49a359c30515aaa813 /app | |
parent | c972699d3975e61785389602bfc8078d3bc40091 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/graphql_controller.rb | 21 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_type.rb | 24 | ||||
-rw-r--r-- | app/services/groups/participants_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/participants_service.rb | 2 |
4 files changed, 38 insertions, 13 deletions
diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index 3d3b7f31dfd..f6a6648fd79 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -14,6 +14,7 @@ class GraphqlController < ApplicationController # The query string of a standard IntrospectionQuery, used to compare incoming requests for caching CACHED_INTROSPECTION_QUERY_STRING = CachedIntrospectionQuery.query_string + INTROSPECTION_QUERY_OPERATION_NAME = 'IntrospectionQuery' # If a user is using their session to access GraphQL, we need to have session # storage, since the admin-mode check is session wide. @@ -58,7 +59,7 @@ class GraphqlController < ApplicationController urgency :low, [:execute] def execute - result = if Feature.enabled?(:cache_introspection_query) && params[:operationName] == 'IntrospectionQuery' + result = if Feature.enabled?(:cache_introspection_query) && introspection_query? execute_introspection_query else multiplex? ? execute_multiplex : execute_query @@ -294,9 +295,7 @@ class GraphqlController < ApplicationController end def introspection_query_can_use_cache? - graphql_query = GraphQL::Query.new(GitlabSchema, query: query, variables: build_variables(params[:variables])) - - CACHED_INTROSPECTION_QUERY_STRING == graphql_query.query_string.squish + CACHED_INTROSPECTION_QUERY_STRING == graphql_query_object.query_string.squish end def introspection_query_cache_key @@ -306,6 +305,15 @@ class GraphqlController < ApplicationController ['introspection-query-cache', Gitlab.revision, context[:remove_deprecated]] end + def introspection_query? + if params.key?(:operationName) + params[:operationName] == INTROSPECTION_QUERY_OPERATION_NAME + else + # If we don't provide operationName param, we infer it from the query + graphql_query_object.selected_operation_name == INTROSPECTION_QUERY_OPERATION_NAME + end + end + def log_introspection_query_cache_details(can_use_introspection_query_cache) Gitlab::AppLogger.info( message: "IntrospectionQueryCache", @@ -315,4 +323,9 @@ class GraphqlController < ApplicationController introspection_query_cache_key: introspection_query_cache_key.to_s ) end + + def graphql_query_object + @graphql_query_object ||= GraphQL::Query.new(GitlabSchema, query: query, + variables: build_variables(params[:variables])) + end end diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb index 8e509cc8493..160ee0234fa 100644 --- a/app/graphql/types/ci/runner_type.rb +++ b/app/graphql/types/ci/runner_type.rb @@ -24,8 +24,9 @@ module Types field :admin_url, GraphQL::Types::String, null: true, description: 'Admin URL of the runner. Only available for administrators.' field :architecture_name, GraphQL::Types::String, null: true, - description: 'Architecture provided by the the runner.', - method: :architecture + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'Architecture provided by the the runner.', + method: :architecture field :contacted_at, Types::TimeType, null: true, description: 'Timestamp of last contact from this runner.', method: :contacted_at @@ -46,15 +47,17 @@ module Types description: 'URL of the registration page of the runner manager. Only available for the creator of the runner for a limited time during registration.', alpha: { milestone: '15.11' } field :executor_name, GraphQL::Types::String, null: true, - description: 'Executor last advertised by the runner.', - method: :executor_name + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'Executor last advertised by the runner.', + method: :executor_name field :groups, null: true, resolver: ::Resolvers::Ci::RunnerGroupsResolver, description: 'Groups the runner is associated with. For group runners only.' field :id, ::Types::GlobalIDType[::Ci::Runner], null: false, description: 'ID of the runner.' field :ip_address, GraphQL::Types::String, null: true, - description: 'IP address of the runner.' + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'IP address of the runner.' field :job_count, GraphQL::Types::Int, null: true, description: "Number of jobs processed by the runner (limited to #{JOB_COUNT_LIMIT}, plus one to indicate that more items exist)." field :job_execution_status, @@ -82,8 +85,9 @@ module Types field :paused, GraphQL::Types::Boolean, null: false, description: 'Indicates the runner is paused and not available to run jobs.' field :platform_name, GraphQL::Types::String, null: true, - description: 'Platform provided by the runner.', - method: :platform + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'Platform provided by the runner.', + method: :platform field :project_count, GraphQL::Types::Int, null: true, description: 'Number of projects that the runner is associated with.' field :projects, @@ -94,7 +98,8 @@ module Types field :register_admin_url, GraphQL::Types::String, null: true, description: 'URL of the temporary registration page of the runner. Only available before the runner is registered. Only available for administrators.' field :revision, GraphQL::Types::String, null: true, - description: 'Revision of the runner.' + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'Revision of the runner.' field :run_untagged, GraphQL::Types::Boolean, null: false, description: 'Indicates the runner is able to run untagged jobs.' field :runner_type, ::Types::Ci::RunnerTypeEnum, null: false, @@ -112,7 +117,8 @@ module Types description: 'Runner token expiration time.', method: :token_expires_at field :version, GraphQL::Types::String, null: true, - description: 'Version of the runner.' + deprecated: { reason: "Use field in `manager` object instead", milestone: '16.2' }, + description: 'Version of the runner.' markdown_field :maintenance_note_html, null: true diff --git a/app/services/groups/participants_service.rb b/app/services/groups/participants_service.rb index 1de2b3c5a2e..b6faf3fd9a5 100644 --- a/app/services/groups/participants_service.rb +++ b/app/services/groups/participants_service.rb @@ -17,7 +17,11 @@ module Groups render_participants_as_hash(participants.uniq) end + private + def all_members + return [] if Feature.enabled?(:disable_all_mention) + count = group_members.count [{ username: "all", name: "All Group Members", count: count }] end diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index 8c807e0016b..44cd6e9926f 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -30,6 +30,8 @@ module Projects end def all_members + return [] if Feature.enabled?(:disable_all_mention) + [{ username: "all", name: "All Project and Group Members", count: project_members.count }] end |