[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/graphql-mode 03312c9f1c 045/122: add variables file suppor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/graphql-mode 03312c9f1c 045/122: add variables file support |
Date: |
Sat, 29 Jan 2022 08:03:31 -0500 (EST) |
branch: elpa/graphql-mode
commit 03312c9f1c2e2595c2cd8fede564c6dd71a93290
Author: Tim Shiu <punshiu@fb.com>
Commit: Tim Shiu <punshiu@fb.com>
add variables file support
---
graphql-mode.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index 79d62df168..14e5cde434 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -62,6 +62,12 @@
:type 'string
:group 'graphql)
+(defcustom graphql-variables nil
+ "file name containing graphql variables."
+ :tag "GraphQL"
+ :type 'file
+ :group 'graphql)
+
(defun graphql--query (query operation variables)
"Send QUERY to the server at `graphql-url' and return the
response from the server."
@@ -128,18 +134,19 @@ response from the server."
(if (string-equal first "{")
nil
(replace-regexp-in-string "[({].*" "" (nth 1 tokens)))))
-
-(defun graphql-current-variables ()
+
+(defun graphql-current-variables (filename)
"get the content of graphql variables from a file"
- nil)
+ (json-encode (json-read-file filename)))
(defun graphql-send-query ()
(interactive)
- (let ((url (or graphql-url (read-string "GraphQL URL: " ))))
+ (let* ((url (or graphql-url (read-string "GraphQL URL: " )))
+ (var (or graphql-variables (read-file-name "Variables File: "))))
(let ((graphql-url url))
(let* ((query (buffer-substring-no-properties (point-min) (point-max)))
(operation (graphql-current-operation))
- (variables (graphql-current-variables))
+ (variables (graphql-current-variables var))
(response (graphql--query query operation variables)))
(with-current-buffer-window
"*GraphQL*" 'display-buffer-pop-up-window nil
@@ -152,6 +159,7 @@ response from the server."
;; in the current buffer (instead of the introduced local
;; binding).
(setq graphql-url url)
+ (setq graphql-variables var)
nil))
(defvar graphql-mode-map
@@ -240,7 +248,7 @@ response from the server."
(,graphql-definition-regex
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))
-
+
;; Constants
(,(regexp-opt graphql-constants) . font-lock-constant-face)
- [nongnu] elpa/graphql-mode 4c87cdab57 018/122: Fix: make the graphql-url buffer-local before the mode is enabled, (continued)
- [nongnu] elpa/graphql-mode 4c87cdab57 018/122: Fix: make the graphql-url buffer-local before the mode is enabled, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 319dfd97d7 011/122: Define graphql-send-query, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode eed3c6ca1c 036/122: Create sample GraphQL server, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 404aa31258 104/122: Save json to graphql-edit-headers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 16c3d63521 002/122: First commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 5bd8b6273e 003/122: fontify more graphql constructions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode bf0412def0 006/122: Better fontification of type [implements X]?, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 1f3bd34b18 064/122: Merge pull request #14 from davazp/next, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode b1aea740ac 052/122: Some fixes to the support of variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode e254c7405d 037/122: graphql-send-query uses the whole buffer, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 03312c9f1c 045/122: add variables file support,
ELPA Syncer <=
- [nongnu] elpa/graphql-mode 09669d4343 089/122: Merge pull request #28 from charles-boyd/enhancement/add-missing-graphql-keywords, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode a20eb1a7cb 100/122: Move code to bottom, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ed589f3cd1 102/122: Simplify buffer killing, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 0596c4ff84 114/122: Use json-encode instead of json-serialize, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7eec227135 098/122: Add header edit buffer UI & stubs, ELPA Syncer, 2022/01/29
- [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