2019-01-24 11:23:57 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
# GraphqlHelpers is used by the REST API when it is acting like a client
|
|
|
|
# against the graphql API. Helper code for the graphql server implementation
|
|
|
|
# should be in app/graphql/ or lib/gitlab/graphql/
|
|
|
|
module GraphqlHelpers
|
2019-10-01 08:05:59 -04:00
|
|
|
def run_graphql!(query:, context: {}, transform: nil)
|
2019-01-24 11:23:57 -05:00
|
|
|
result = GitlabSchema.execute(query, context: context)
|
|
|
|
|
|
|
|
if transform
|
|
|
|
transform.call(result)
|
|
|
|
else
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|