From ef2cd26b0fe415d7d8398e26b6a4d7257fd38afd Mon Sep 17 00:00:00 2001 From: Dan Lecocq Date: Fri, 15 Mar 2024 15:54:23 -0600 Subject: [PATCH 1/2] Failing tests about dealing with non-string computed keys --- graphql/keys_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/graphql/keys_test.go b/graphql/keys_test.go index e7c18c2..8ab3959 100644 --- a/graphql/keys_test.go +++ b/graphql/keys_test.go @@ -40,6 +40,21 @@ func TestComputeMutationVariableKeys(t *testing.T) { computeKeys: map[string]interface{}{"id_key": "todos[1]"}, expectedValues: map[string]interface{}{"id_key": "another"}, }, + { + body: `{"data": {"id": 1}}`, + computeKeys: map[string]interface{}{"id_key": "id"}, + expectedValues: map[string]interface{}{"id_key": "1"}, + }, + { + body: `{"data": {"pi": 3.14159}}`, + computeKeys: map[string]interface{}{"id_key": "pi"}, + expectedValues: map[string]interface{}{"id_key": "3.14159"}, + }, + { + body: `{"data": {"ready": false}}`, + computeKeys: map[string]interface{}{"id_key": "ready"}, + expectedValues: map[string]interface{}{"id_key": "false"}, + }, { body: `{"data": {"todos": [{"id": "computed_id"}, {"id": "second_id"}]}}`, computeKeys: map[string]interface{}{"id_key": "todos[3].id"}, From d279b43a720452f6bf538ecaf59bd691d77bd75f Mon Sep 17 00:00:00 2001 From: Dan Lecocq Date: Fri, 15 Mar 2024 15:54:34 -0600 Subject: [PATCH 2/2] Passing tests about dealing with non-string computed keys --- graphql/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql/keys.go b/graphql/keys.go index ad4793f..4826828 100644 --- a/graphql/keys.go +++ b/graphql/keys.go @@ -33,7 +33,7 @@ func computeMutationVariableKeys(keyMaps map[string]interface{}, responseObject if err != nil { return nil, err } - mvks[k] = key.(string) + mvks[k] = fmt.Sprintf("%v", key) } return mvks, nil }