Skip to content

Commit cdf20f7

Browse files
Address code review feedback
** Why are these changes being introduced: * Rather than simply replacing geopoint with geoshape, we are going to keep geopoint in the code, but mark it as deprecated. This is the recommended workflow for making changes in GraphQL (which we are following here to reinforce the practice, even though this particular field has never been populated) ** How does this address that need: * This brings back the geopoint field in the LocationType definition, but markes it deprecated in the schema. * We add a method to the Location type that populates the geopoint field with the contents of the geoshape field. Ironically, this is likely the first time that the geopoint field has been able to respond with any values at all. * We also update the test to include reference to this now-deprecated field. ** Document any side effects to this change: * Is it a side effect to be, effectively, adding content to the geopoint field only as we mark it deprecated?
1 parent c00a14a commit cdf20f7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/graphql/types/record_type.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,14 @@ class AlternateTitleType < Types::BaseObject
108108

109109
# Warning: related_place was supposed to be an array but was incorrectly a string in graphql for v1
110110
class LocationType < Types::BaseObject
111+
field :geopoint, String, deprecation_reason: 'Use `geoshape`'
111112
field :geoshape, String, description: 'GeoShape data for the location, if applicable'
112113
field :kind, String, description: 'Type of location'
113114
field :value, String, description: 'Name of location'
115+
116+
def geopoint
117+
@object['geoshape']
118+
end
114119
end
115120

116121
class HighlightType < Types::BaseObject

test/controllers/graphql_controller_v2_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ def setup
460460
search(searchterm: "train stations") {
461461
records {
462462
locations {
463+
geopoint
463464
geoshape
464465
kind
465466
value
@@ -473,7 +474,7 @@ def setup
473474
assert_not json['errors'].present?
474475
assert_equal(
475476
json['data']['search']['records'].first['locations'][0].keys.sort,
476-
["geoshape", "value", "kind"].sort
477+
["geopoint", "geoshape", "value", "kind"].sort
477478
)
478479
end
479480
end

0 commit comments

Comments
 (0)