[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/graphql-mode 36dc6e6c9d 042/122: Update with David feedbac
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/graphql-mode 36dc6e6c9d 042/122: Update with David feedback |
Date: |
Sat, 29 Jan 2022 08:03:31 -0500 (EST) |
branch: elpa/graphql-mode
commit 36dc6e6c9dee2527499483fda06b0b06fa8a7325
Author: Tim Shiu <punshiu@fb.com>
Commit: Tim Shiu <punshiu@fb.com>
Update with David feedback
---
graphql-mode.el | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index a8e6c08e27..5e91075f4f 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -51,22 +51,25 @@
(defcustom graphql-indent-level 2
"Number of spaces for each indentation step in `graphql-mode'."
+ :tag "GraphQL"
:type 'integer
:safe 'integerp)
+(defcustom graphql-url "http://localhost:8000/graphql"
+ "URL address of the graphql server endpoint."
+ :tag "GraphQL"
+ :type 'string)
-(defvar graphql-url
- nil)
-(make-variable-buffer-local 'graphql-url)
-
-(defun graphql--query (query)
+(defun graphql--query (query operation variables)
"Send QUERY to the server at `graphql-url' and return the
response from the server."
(let* ((url-request-method "POST")
- (query (url-encode-url query))
- (operation (graphql-current-operation))
- (variables (url-encode-url (graphql-current-variables)))
- (url (format "%s?query=%s&operationName=%s&variables=%s" graphql-url
query operation variables)))
+ (query (url-encode-url query))
+ (url (format "%s?query=%s" graphql-url query)))
+ (if operation
+ (setq url (concat url "&operationName=" operation)))
+ (if variables
+ (setq url (concat url "&variables=" (url-encode-url variables))))
(with-current-buffer (url-retrieve-synchronously url t)
(goto-char (point-min))
(search-forward "\n\n")
@@ -107,13 +110,13 @@ response from the server."
(let* ((query
(save-excursion
(replace-regexp-in-string "^[ \t\n]*" "" (graphql-current-query))))
- (tokens
- (split-string query "[ \f\t\n\r\v]+"))
- (first (nth 0 tokens)))
+ (tokens
+ (split-string query "[ \f\t\n\r\v]+"))
+ (first (nth 0 tokens)))
(if (string-equal first "{")
- ""
- (replace-regexp-in-string "[({:]+" "" (nth 1 tokens)))))
+ nil
+ (replace-regexp-in-string "[({].*" "" (nth 1 tokens)))))
(defun graphql-current-variables ()
"get the content of graphql variables"
@@ -124,8 +127,9 @@ response from the server."
(search-backward-regexp "^variables" (point-min) t)
(search-forward-regexp "^variables" (point-max) t)
(point))))
- (buffer-substring-no-properties variables (point-max))
- ))
+ (if (eq variables (point-max))
+ nil
+ (buffer-substring-no-properties variables (point-max)))))
(defun graphql-beginning-of-variables ()
"get the beginning point of graphql variables"
@@ -141,7 +145,9 @@ response from the server."
(let ((url (or graphql-url (read-string "GraphQL URL: " ))))
(let ((graphql-url url))
(let* ((query (buffer-substring-no-properties (point-min)
(graphql-beginning-of-variables)))
- (response (graphql--query query)))
+ (operation (graphql-current-operation))
+ (variables (graphql-current-variables))
+ (response (graphql--query query operation variables)))
(with-current-buffer-window
"*GraphQL*" 'display-buffer-pop-up-window nil
(erase-buffer)
- [nongnu] elpa/graphql-mode c3f7b9d827 105/122: Use unique buffer name, not full path, (continued)
- [nongnu] elpa/graphql-mode c3f7b9d827 105/122: Use unique buffer name, not full path, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 1912bd08f5 118/122: Merge pull request #43 from phikal/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 80e9ac8020 119/122: Provide a link to what a graphqlconfig file is., ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 5e294e8160 120/122: Fix parameters defined on the same line not always fontified, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ec3c72cd28 016/122: Support enum definitions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ad54fdb48a 022/122: Improve package description, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 66efefd508 027/122: Add customization group and variable to customize indentation level, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ef2933eb92 020/122: Add autoload cookie to auto-mode-alist setting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7d954d0045 035/122: Fix font lock to highlight whole symbols, not just words, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 3c25bf5cbd 040/122: Adapt more regexs to understand _ as part f symbols, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 36dc6e6c9d 042/122: Update with David feedback,
ELPA Syncer <=
- [nongnu] elpa/graphql-mode dec32e6441 021/122: Fix package dependencies, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 3ddf204de7 031/122: Add mailmap to merge author lines, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode a37919f2ab 065/122: graphql--query: Remove unused lexical variable, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode cf2622cb21 049/122: Update feedback from David, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode d3aa4d66e0 013/122: Extract constants and values into separate variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 1bff11f21c 056/122: fix the line-boundary issue to enhance {} sexp, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ba5952590c 079/122: Merge pull request #22 from cbowdon/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 061d6d0b34 001/122: Initial commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode cbd07029fa 009/122: Better indentation of closing pairs, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 096df5b167 005/122: Basic line indentation, ELPA Syncer, 2022/01/29