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

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

[nongnu] elpa/graphql-mode 74ee772a62 087/122: Merge pull request #26 fr


From: ELPA Syncer
Subject: [nongnu] elpa/graphql-mode 74ee772a62 087/122: Merge pull request #26 from Malabarba/master
Date: Sat, 29 Jan 2022 08:03:37 -0500 (EST)

branch: elpa/graphql-mode
commit 74ee772a62103fe3ec4f291854a0604dd3f5bb9e
Merge: ebd6502c09 4c942986fa
Author: David Vázquez Púa <davazp@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #26 from Malabarba/master
    
    Also insert response headers in the buffer (with comment face)
---
 graphql-mode.el | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/graphql-mode.el b/graphql-mode.el
index f39aa4d5ce..cdac300b3b 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -110,20 +110,18 @@ VARIABLES list of variables for query operation"
       (error "graphql-post-request needs the request package.  \
 Please install it and try again."))
   (let* ((body (graphql-encode-json query operation variables))
-         (headers (append '(("Content-Type" . "application/json")) 
graphql-extra-headers))
-         (response (request
-                    url
-                    :type "POST"
-                    :data body
-                    :headers headers
-                    :parser 'json-read
-                    :sync t
-                    :complete (lambda (&rest _)
-                                (message "%s" (if (string-equal "" operation)
-                                                  url
-                                                (format "%s?operationName=%s"
-                                                        url operation)))))))
-    (json-encode (request-response-data response))))
+         (headers (append '(("Content-Type" . "application/json")) 
graphql-extra-headers)))
+    (request url
+             :type "POST"
+             :data body
+             :headers headers
+             :parser 'json-read
+             :sync t
+             :complete (lambda (&rest _)
+                         (message "%s" (if (string-equal "" operation)
+                                           url
+                                         (format "%s?operationName=%s"
+                                                 url operation)))))))
 
 (defun graphql-beginning-of-query ()
   "Move the point to the beginning of the current query."
@@ -213,8 +211,13 @@ Please install it and try again."))
          ;;
          ;; (when (fboundp 'json-mode)
          ;;   (json-mode))
-         (insert response)
-         (json-pretty-print-buffer))))
+         (insert (json-encode (request-response-data response)))
+         (json-pretty-print-buffer)
+         (goto-char (point-max))
+         (insert "\n\n"
+                 (propertize (request-response--raw-header response)
+                             'face 'font-lock-comment-face
+                             'font-lock-face 'font-lock-comment-face)))))
     ;; If the query was successful, then save the value of graphql-url
     ;; in the current buffer (instead of the introduced local
     ;; binding).



reply via email to

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