emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/graphql-mode de4b2e8117 039/122: Remember graphql-url valu


From: ELPA Syncer
Subject: [nongnu] elpa/graphql-mode de4b2e8117 039/122: Remember graphql-url value only if the query is successful
Date: Sat, 29 Jan 2022 08:03:31 -0500 (EST)

branch: elpa/graphql-mode
commit de4b2e8117f26e5ad98387f715ce4c6cffa40c73
Author: David Vazquez Pua <dvazquezpua@deloitte.nl>
Commit: David Vazquez Pua <dvazquezpua@deloitte.nl>

    Remember graphql-url value only if the query is successful
    
    This fixes #6
---
 graphql-mode.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/graphql-mode.el b/graphql-mode.el
index cc14d75a6f..0dd61afdb7 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -99,17 +99,22 @@ response from the server."
 
 (defun graphql-send-query ()
   (interactive)
-  (unless graphql-url
-    (setq graphql-url (read-string "GraphQL URL: " )))
-  (let* ((query (buffer-substring-no-properties (point-min) (point-max)))
-         (response (graphql--query query)))
-    (with-current-buffer-window
-     "*GraphQL*" 'display-buffer-pop-up-window nil
-     (erase-buffer)
-     (when (fboundp 'json-mode)
-       (json-mode))
-     (insert response)
-     (json-pretty-print-buffer))))
+  (let ((url (or graphql-url (read-string "GraphQL URL: " ))))
+    (let ((graphql-url url))
+      (let* ((query (buffer-substring-no-properties (point-min) (point-max)))
+             (response (graphql--query query)))
+        (with-current-buffer-window
+         "*GraphQL*" 'display-buffer-pop-up-window nil
+         (erase-buffer)
+         (when (fboundp 'json-mode)
+           (json-mode))
+         (insert response)
+         (json-pretty-print-buffer))))
+    ;; If the query was successful, then save the value of graphql-url
+    ;; in the current buffer (instead of the introduced local
+    ;; binding).
+    (setq graphql-url url)
+    nil))
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]