From e59d3f400f5f06e91b5d100a121546e8e163b506 Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Mon, 2 Dec 2024 16:45:43 +0000 Subject: [PATCH 1/2] Return GraphQL response as `GdsApi::Response` This is instead of `Hash`. In Government Frontend, we need some other information from the request response (e.g. the cache control headers) which are not included when the response is converted to a hash. This is not a breaking change as the new object type accepts the same methods as the hash. --- lib/gds_api/publishing_api.rb | 4 ++-- test/test_helpers/publishing_api_test.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gds_api/publishing_api.rb b/lib/gds_api/publishing_api.rb index 7fa460b8..e7c71a0c 100644 --- a/lib/gds_api/publishing_api.rb +++ b/lib/gds_api/publishing_api.rb @@ -562,9 +562,9 @@ def get_schema(schema_name) # # @param query [String] # - # @return [Hash] A response with the result of the GraphQL query. + # @return [GdsApi::Response] A response with the result of the GraphQL query. def graphql_query(query) - post_json("#{endpoint}/graphql", query:).to_hash + post_json("#{endpoint}/graphql", query:) end private diff --git a/test/test_helpers/publishing_api_test.rb b/test/test_helpers/publishing_api_test.rb index 68085a7f..bcbb7a9e 100644 --- a/test/test_helpers/publishing_api_test.rb +++ b/test/test_helpers/publishing_api_test.rb @@ -632,7 +632,7 @@ assert_equal( stubbed_response.to_json, - api_response.to_json, + api_response.raw_response_body, ) end end From 96ac0d7106d2976a1ffc11a3a27e67547f60acf5 Mon Sep 17 00:00:00 2001 From: Bruce Bolt Date: Mon, 2 Dec 2024 16:48:42 +0000 Subject: [PATCH 2/2] Release version 97.5.0 --- CHANGELOG.md | 4 ++++ lib/gds_api/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2923982a..d0fab048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 97.5.0 + +* Return response to GraphQL endpoint as `GdsApi::Response` instead of `Hash` [PR](https://github.com/alphagov/gds-api-adapters/pull/1304). + ## 97.4.1 * Add rollup data to host content endpoint [PR](https://github.com/alphagov/gds-api-adapters/pull/1300) diff --git a/lib/gds_api/version.rb b/lib/gds_api/version.rb index 1e48d40a..ebf80618 100644 --- a/lib/gds_api/version.rb +++ b/lib/gds_api/version.rb @@ -1,3 +1,3 @@ module GdsApi - VERSION = "97.4.1".freeze + VERSION = "97.5.0".freeze end