branch: elpa/graphql-mode
commit ead2f85e12ef31d76b3c3b77cd00e81ecd352fa0
Author: Tim Shiu <[email protected]>
Commit: Tim Shiu <[email protected]>
add error handling
---
graphql-mode.el | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index f211fdf0c3..04b2217ff1 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -137,13 +137,22 @@ response from the server."
(defun graphql-current-variables (filename)
"get the content of graphql variables from a file"
- (json-encode (json-read-file filename)))
+ (if (and filename
+ (not (string-equal filename ""))
+ (not (file-directory-p filename))
+ (file-exists-p filename))
+ (condition-case nil
+ (json-encode (json-read-file filename))
+ (error nil))
+ nil))
(defun graphql-send-query ()
(interactive)
(let* ((url (or graphql-url (read-string "GraphQL URL: " )))
(var (or graphql-variables (read-file-name "Variables File: "))))
- (let ((graphql-url url))
+ (let ((graphql-url url)
+ (graphql-variables var))
+
(let* ((query (buffer-substring-no-properties (point-min) (point-max)))
(operation (graphql-current-operation))
(variables (graphql-current-variables var))