diff options
author | Nick Thomas <nick@gitlab.com> | 2019-01-24 19:23:57 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-03-05 18:00:32 +0300 |
commit | 21779d00186d75349165d6c07dbe04aace68017c (patch) | |
tree | 25aaf112b51d6f5360a3e97db6f31f98a642660e /app/graphql | |
parent | 42d3117f9c3371e07e8b0aafab6f504e87251c2a (diff) |
Add metadata about the GitLab server to GraphQL
Diffstat (limited to 'app/graphql')
-rw-r--r-- | app/graphql/resolvers/metadata_resolver.rb | 11 | ||||
-rw-r--r-- | app/graphql/types/metadata_type.rb | 10 | ||||
-rw-r--r-- | app/graphql/types/query_type.rb | 10 |
3 files changed, 30 insertions, 1 deletions
diff --git a/app/graphql/resolvers/metadata_resolver.rb b/app/graphql/resolvers/metadata_resolver.rb new file mode 100644 index 00000000000..3a79e6434fb --- /dev/null +++ b/app/graphql/resolvers/metadata_resolver.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Resolvers + class MetadataResolver < BaseResolver + type Types::MetadataType, null: false + + def resolve(**args) + { version: Gitlab::VERSION, revision: Gitlab.revision } + end + end +end diff --git a/app/graphql/types/metadata_type.rb b/app/graphql/types/metadata_type.rb new file mode 100644 index 00000000000..2d8bad0614b --- /dev/null +++ b/app/graphql/types/metadata_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Types + class MetadataType < ::Types::BaseObject + graphql_name 'Metadata' + + field :version, GraphQL::STRING_TYPE, null: false + field :revision, GraphQL::STRING_TYPE, null: false + end +end diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 954bcc0a5a3..472fe5d6ec2 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Types - class QueryType < BaseObject + class QueryType < ::Types::BaseObject graphql_name 'Query' field :project, Types::ProjectType, @@ -10,6 +10,14 @@ module Types description: "Find a project", authorize: :read_project + field :metadata, Types::MetadataType, + null: true, + resolver: Resolvers::MetadataResolver, + description: 'Metadata about GitLab' do |*args| + + authorize :read_instance_metadata + end + field :echo, GraphQL::STRING_TYPE, null: false, function: Functions::Echo.new end end |