summaryrefslogtreecommitdiff
path: root/lib/bulk_imports/clients/graphql.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bulk_imports/clients/graphql.rb')
-rw-r--r--lib/bulk_imports/clients/graphql.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/bulk_imports/clients/graphql.rb b/lib/bulk_imports/clients/graphql.rb
index ca549c4be14..0adc2b1c57f 100644
--- a/lib/bulk_imports/clients/graphql.rb
+++ b/lib/bulk_imports/clients/graphql.rb
@@ -23,15 +23,19 @@ module BulkImports
attr_reader :client
- delegate :query, :parse, :execute, to: :client
+ delegate :query, :parse, to: :client
def initialize(url: Gitlab::Saas.com_url, token: nil)
@url = Gitlab::Utils.append_path(url, '/api/graphql')
@token = token
- @client = Graphlient::Client.new(
- @url,
- options(http: HTTP)
- )
+ @client = Graphlient::Client.new(@url, options(http: HTTP))
+ @compatible_instance_version = false
+ end
+
+ def execute(*args)
+ validate_instance_version!
+
+ client.execute(*args)
end
def options(extra = {})
@@ -44,6 +48,19 @@ module BulkImports
}
}.merge(extra)
end
+
+ def validate_instance_version!
+ return if @compatible_instance_version
+
+ response = client.execute('{ metadata { version } }')
+ version = Gitlab::VersionInfo.parse(response.data.metadata.version)
+
+ if version.major < BulkImport::MINIMUM_GITLAB_MAJOR_VERSION
+ raise ::BulkImports::Error.unsupported_gitlab_version
+ else
+ @compatible_instance_version = true
+ end
+ end
end
end
end