[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/graphql-mode 321c1f4b64 095/122: Implement support for loa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/graphql-mode 321c1f4b64 095/122: Implement support for loading graphql-configs |
Date: |
Sat, 29 Jan 2022 08:03:38 -0500 (EST) |
branch: elpa/graphql-mode
commit 321c1f4b64283b67eed641d2468df0f8a58a3a31
Author: Reed Mullanix <reed.mullanix@mybazinga.com>
Commit: David Vázquez Púa <davazp@gmail.com>
Implement support for loading graphql-configs
---
graphql-mode.el | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/graphql-mode.el b/graphql-mode.el
index 06793d24a1..ea64b085a4 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -40,6 +40,7 @@
(require 'json)
(require 'url)
(require 'cl-lib)
+(require 'let-alist)
;;; User Customizations:
@@ -73,6 +74,33 @@
:type 'list
:group 'graphql)
+(defun graphql-locate-config (dir)
+ "Locate a graphql config starting in DIR."
+ (if-let ((config-dir (locate-dominating-file dir ".graphqlconfig")))
+ (concat config-dir ".graphqlconfig")
+ (error "Could not find a .graphqlconfig file")))
+
+(defun graphql--completing-read-endpoint (endpoints)
+ "Select an endpoint configuration from a list of ENDPOINTS."
+ (completing-read "Select Graphql Endpoint:" (mapcar 'car endpoints)))
+
+(defun graphql-open-config ()
+ "Open the graphql config."
+ (interactive)
+ (find-file (graphql-locate-config ".")))
+
+(defun graphql-select-endpoint ()
+ "Set parameters based off of the endpoints listed in a .graphqlconfig file."
+ (interactive)
+ (let ((config (json-read-file (graphql-locate-config "."))))
+ (let-alist config
+ (if-let ((endpoints .extensions.endpoints)
+ (endpoint (cdr (assq (intern (graphql--completing-read-endpoint
endpoints)) endpoints))))
+ (let-alist endpoint
+ (setq graphql-url .url
+ graphql-extra-headers .headers))
+ (error "No endpoint configurations in .graphqlconfig")))))
+
(defun graphql-encode-json (query &optional operation variables)
"Put together a json like object with QUERY, OPERATION, and VARIABLES."
(let* ((body '()))
@@ -231,6 +259,7 @@ Please install it and try again."))
(defvar graphql-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'graphql-send-query)
+ (define-key map (kbd "C-c C-l") 'graphql-select-endpoint)
map)
"Key binding for GraphQL mode.")
- [nongnu] elpa/graphql-mode 5e7665dfc4 059/122: forget the actual changes, (I have two location to dev/test), (continued)
- [nongnu] elpa/graphql-mode 5e7665dfc4 059/122: forget the actual changes, (I have two location to dev/test), ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 2326c1fb18 034/122: Merge pull request #7 from eoma/fix-url, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 04e56ae626 053/122: Disable json-mode for response temporarily, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode ab58192967 081/122: Merge pull request #23 from leoliu/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode c643d53a4b 083/122: Don't send operationName when operation is an empty string, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 09a9af6c98 075/122: Merge remote-tracking branch 'origin/master' into next, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode b802f77542 068/122: graphql-send-query: Silence byte-compiler, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 4aebf7afd9 066/122: graphql-post-request: Use URL instead of missing ENDPOINT, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7c37aee28b 096/122: Open .gql files automatically as well, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 1125c2136d 055/122: extend graphql-current-operation to support 'line' boundary if sexp fail, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 321c1f4b64 095/122: Implement support for loading graphql-configs,
ELPA Syncer <=
- [nongnu] elpa/graphql-mode 033f6a074c 082/122: Don't use temp buffer, as it breaks local variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 63cd55ed7d 099/122: Implement abort behaviour, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 7088db7250 091/122: Merge pull request #29 from Prillan/enable-json-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 9bed568ec8 097/122: Add Homepage header, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 4147fbfd97 109/122: Refuse to open g-e-h unless in graphql-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 562d13fc20 101/122: Factor out buffer closing code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode af9b235e14 103/122: Add content of graphql-extra-headers to buffer, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 3581ad03e0 094/122: Allow *GraphQL* response buffer to be closed with "q" key, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 22361631a1 111/122: Add documentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/graphql-mode 99850e1012 110/122: Don't clobber contents of existing buffer, ELPA Syncer, 2022/01/29