branch: externals/graphql
commit d299be77dab1b7814e6a7887bc9b831562814d4a
Author: Sean Allred <c...@seanallred.com>
Commit: Sean Allred <c...@seanallred.com>

    Tweak handling for numbers when encoding argument values.
    
    Also pull out a new function `graphql--encode-argument-value' from
    `graphql--encode-argument'.
---
 graphql.el              | 30 +++++++++++++++---------------
 test/graphql.el-test.el |  4 ++--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/graphql.el b/graphql.el
index 7e6ab60e6b..8fd623622b 100644
--- a/graphql.el
+++ b/graphql.el
@@ -46,21 +46,21 @@
 (defun graphql--encode-argument-spec (spec)
   (graphql--encode-argument (car spec) (cdr spec)))
 (defun graphql--encode-argument (key value)
-  (format "%s:%s"
-          key
-          (cond
-           ((symbolp value)
-            (symbol-name value))
-           ((eq '$ (car-safe value))
-            (format "$%s" (cadr value)))
-           ((listp value)
-            (format "{%s}" (mapconcat #'graphql--encode-argument-pair value 
",")))
-           ((stringp value)
-            (format "\"%s\"" value))
-           ((numberp value)
-            value)
-           (t
-            (graphql--encode value)))))
+  (format "%s:%s" key (graphql--encode-argument-value value)))
+(defun graphql--encode-argument-value (value)
+  (cond
+   ((symbolp value)
+    (symbol-name value))
+   ((eq '$ (car-safe value))
+    (format "$%s" (cadr value)))
+   ((listp value)
+    (format "{%s}" (mapconcat #'graphql--encode-argument-spec value ",")))
+   ((stringp value)
+    (format "\"%s\"" value))
+   ((numberp value)
+    (number-to-string value))
+   (t
+    (graphql--encode value))))
 
 (defun graphql--get-keys (g)
   (let (graph keys)
diff --git a/test/graphql.el-test.el b/test/graphql.el-test.el
index ff95124e62..457bb7f5f2 100644
--- a/test/graphql.el-test.el
+++ b/test/graphql.el-test.el
@@ -8,10 +8,10 @@
 
   (should (string= (graphql-encode
                     '(query
-                      :arguments ((one . "1")
+                      :arguments ((one . 1)
                                   (two . "2"))
                       hello-world))
-                   "query(one:\"1\",two:\"2\") { hello-world }"))
+                   "query(one:1,two:\"2\") { hello-world }"))
 
   (should (string= (graphql-encode
                     '(query

Reply via email to