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
|
2021-03-23 05:09:17 -04:00
|
|
|
def run_graphql!(query:, context: {}, variables: nil, transform: nil)
|
|
|
|
result = GitlabSchema.execute(query, variables: variables, context: context)
|
2019-01-24 11:23:57 -05:00
|
|
|
|
|
|
|
if transform
|
|
|
|
transform.call(result)
|
|
|
|
else
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|