[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/graphql-mode 052491e05f 048/122: update variable encoding
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/graphql-mode 052491e05f 048/122: update variable encoding in post body, ask operation Name if needed |
Date: |
Sat, 29 Jan 2022 08:03:32 -0500 (EST) |
branch: elpa/graphql-mode
commit 052491e05f05c37dbbd9e3553cb4e38936f92d83
Author: Tim Shiu <punshiu@fb.com>
Commit: Tim Shiu <punshiu@fb.com>
update variable encoding in post body, ask operation Name if needed
---
graphql-mode.el | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index 04b2217ff1..a6b5df221d 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -77,21 +77,25 @@ response from the server."
(setq url (concat url "&operationName=" operation)))
(if variables
(setq url (concat url "&variables=" (url-encode-url variables))))
- (with-temp-buffer (graphql-post-request url query operation variables))))
+ (with-temp-buffer (graphql-post-request graphql-url url query operation
variables))))
-(defun graphql-post-request (url query operation variables)
+(defun graphql-post-request (host_path url query operation variables)
"graphql make post request to graphql endpoint url with body of query,
operationName, and variables"
(let* ((body (list (cons "query" query)
(cons "operationName" operation)
- (cons "variables" (json-encode variables))))
- (response (request
+ (cons "variables" variables)))
+ (response nil))
+ (setq response (request
url
:type "POST"
:data (json-encode body)
:headers '(("Content-Type" . "application/json"))
:parser 'json-read
:sync t
- )))
+ :complete (lambda (&rest _)
+ (message "%s" (if (string-equal "" operation)
+ host_path
+ (format "%s?operationName=%s"
host_path operation))))))
(json-encode (request-response-data response))))
(defun graphql-beginning-of-query ()
@@ -131,8 +135,8 @@ response from the server."
(split-string query "[ \f\t\n\r\v]+"))
(first (nth 0 tokens)))
- (if (string-equal first "{")
- nil
+ (if (or (string-equal first "{") (string-equal first ""))
+ (read-string "GraphQL operation: ")
(replace-regexp-in-string "[({].*" "" (nth 1 tokens)))))
(defun graphql-current-variables (filename)
@@ -142,14 +146,15 @@ response from the server."
(not (file-directory-p filename))
(file-exists-p filename))
(condition-case nil
- (json-encode (json-read-file filename))
+ (progn (display-buffer (find-file-noselect filename))
+ (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: "))))
+ (var (or graphql-variables (read-file-name "GraphQL Variables: "))))
(let ((graphql-url url)
(graphql-variables var))
- [nongnu] elpa/graphql-mode 1b78d07aee 092/122: declare request-response--raw-header function, (continued)
- [nongnu] elpa/graphql-mode 1b78d07aee 092/122: declare request-response--raw-header function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 9740e4027b 122/122: Merge pull request #45 from LaurenceWarne/parameter-fontlock-fix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode d9fa01b446 004/122: Improve highlight of definitions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 347431ce18 007/122: Fontify fragments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 836373c72e 010/122: Basic support for imenu, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 497529dd4d 008/122: Fontify query, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 26a5d8a665 043/122: make graphql-current-* function, not command. also graphql-begining-of-variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 6e1f5335fa 030/122: Mention json-mode in the README.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 8a4a5fae69 015/122: Fontify field arguments as variable names, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7798aef2a8 029/122: Fix typo, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 052491e05f 048/122: update variable encoding in post body, ask operation Name if needed,
ELPA Syncer <=
- [nongnu] elpa/graphql-mode 83cba48fd8 014/122: Remove unnecessary syntax, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 6017afac92 017/122: Rename graphql.el to graphql-mode.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7482c1b100 025/122: Add basic commentary, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 36b1a4ed9f 070/122: Merge pull request #16 from emacsjanitors/no-request, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 4b0134a19a 050/122: forget docstring, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 5f2ee4b3b3 024/122: Add melpa badge, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 8e58196e21 023/122: Merge pull request #1 from syohex/fix-package, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 2ee89d4e05 080/122: Fix Error during redisplay, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 0b4152d485 051/122: Fix tests to use variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 74ee772a62 087/122: Merge pull request #26 from Malabarba/master, ELPA Syncer, 2022/01/29