Module: ActiveProject::Adapters::GithubProject::Connection::InstanceGraphqlPatcher

Defined in:
lib/active_project/adapters/github_project/connection.rb

Instance Method Summary collapse

Instance Method Details

#handle_deprecation_warnings!(res) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_project/adapters/github_project/connection.rb', line 38

def handle_deprecation_warnings!(res)
  warnings = res.dig("extensions", "warnings") || []
  warnings.each do |w|
    next unless w["type"] == "DEPRECATION"

    legacy = w.dig("data", "legacy_global_id")
    updated = w.dig("data", "next_global_id")
    next unless legacy && updated

    (@_deprecation_map ||= {})[legacy] = updated
  end
end

#request_gql(query:, variables: {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/active_project/adapters/github_project/connection.rb', line 30

def request_gql(query:, variables: {})
  payload = { query: query, variables: variables }.to_json
  res = request(:post, "", body: payload)
  handle_deprecation_warnings!(res)
  raise_graphql_errors!(res)
  res["data"]
end

#upgraded_id(legacy_id) ⇒ Object



51
52
53
# File 'lib/active_project/adapters/github_project/connection.rb', line 51

def upgraded_id(legacy_id)
  @_deprecation_map&.fetch(legacy_id, legacy_id)
end