From 177457f74dcc4e1cf900d577b57eb3500d3bfb73 Mon Sep 17 00:00:00 2001 From: laststylebender Date: Tue, 3 Sep 2024 01:27:00 +0530 Subject: [PATCH] - treat null responses as JSON scalars as we don't know the shape of output. --- src/core/helpers/gql_type.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/helpers/gql_type.rs b/src/core/helpers/gql_type.rs index 46bc24b32f..8d4da11518 100644 --- a/src/core/helpers/gql_type.rs +++ b/src/core/helpers/gql_type.rs @@ -25,7 +25,11 @@ pub fn is_valid_field_name(property_name: &str) -> bool { pub fn to_gql_type(value: &Value) -> String { match value { - Value::Null => "Empty", + Value::Null => { + // treat null values as JSON scalars as we don't know the exact shape of the + // output. + "JSON" + } Value::Bool(_) => "Boolean", Value::Number(_) => "Int", Value::String(_) => "String", @@ -81,7 +85,7 @@ mod test { assert_eq!(to_gql_type(&json!(false)), "Boolean"); assert_eq!(to_gql_type(&json!([1, 2, 3])), "List"); assert_eq!(to_gql_type(&json!({"name":"test", "age": 12})), "Object"); - assert_eq!(to_gql_type(&Value::Null), "Empty"); + assert_eq!(to_gql_type(&Value::Null), "JSON"); assert_eq!(to_gql_type(&json!([])), "List"); assert_eq!(to_gql_type(&json!({})), "Object");