diff --git a/lib/fbe/github_graph.rb b/lib/fbe/github_graph.rb index b30c9bf..2d0a61e 100644 --- a/lib/fbe/github_graph.rb +++ b/lib/fbe/github_graph.rb @@ -490,11 +490,12 @@ def total_releases_published(owner, name, since) total = 0 cursor = nil loop do + after = "after: \"#{cursor}\", " unless cursor.nil? result = query( <<~GRAPHQL { repository(owner: "#{owner}", name: "#{name}") { - releases(first: 25, after: "#{cursor}", orderBy: { field: CREATED_AT, direction: DESC }) { + releases(#{after}first: 25, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { isDraft publishedAt diff --git a/test/fbe/test_github_graph.rb b/test/fbe/test_github_graph.rb index 4ff5529..1c03586 100644 --- a/test/fbe/test_github_graph.rb +++ b/test/fbe/test_github_graph.rb @@ -315,4 +315,17 @@ def test_pull_request_reviews_omits_after_when_cursor_is_nil graph.pull_request_reviews('foo', 'bar', pulls: [[2, nil]]) refute_includes(captured, 'after: ""') end + + def test_total_releases_published_omits_after_when_cursor_is_nil + WebMock.disable_net_connect! + graph = Fbe::Graph.new(token: 'fake') + captured = nil + releases = { 'nodes' => [], 'pageInfo' => { 'hasNextPage' => false, 'endCursor' => nil } } + graph.define_singleton_method(:query) do |qry| + captured = qry + { 'repository' => { 'releases' => releases } } + end + graph.total_releases_published('foo', 'bar', Time.parse('2025-12-16T15:00:00Z')) + refute_includes(captured, 'after: ""') + end end