branch: elpa/graphql-mode
commit fb84a08434a3a4fd8a0c2914bdd92f35d29bef22
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
Make the dependency on request optional
The functionality for making a request is not directly related to the
major-mode. Users should be able to use the major-mode without having
to install `request'.
---
graphql-mode.el | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/graphql-mode.el b/graphql-mode.el
index b82c7248b2..38b72275b5 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -4,7 +4,7 @@
;; Author: David Vazquez Pua <[email protected]>
;; Keywords: languages
-;; Package-Requires: ((emacs "24.3") (request "20170131.1747"))
+;; Package-Requires: ((emacs "24.3"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -40,7 +40,6 @@
(require 'json)
(require 'url)
(require 'cl-lib)
-(require 'request)
;;; User Customizations:
@@ -89,6 +88,9 @@ of the variables used in the query."
(with-temp-buffer
(graphql-post-request graphql-url query operation variables)))
+(declare-function request "request")
+(declare-function request-response-data "request")
+
(defun graphql-post-request (url query &optional operation variables)
"Make post request to graphql server with url and body.
@@ -96,6 +98,9 @@ URL hostname, path, search parameters, such as operationName
and variables
QUERY query definition(s) of query, mutation, and/or subscription
OPERATION name of the operation if multiple definition is given in QUERY
VARIABLES list of variables for query operation"
+ (or (require 'request nil t)
+ (error "graphql-post-request needs the request package. \
+Please install it and try again."))
(let* ((body (graphql-encode-json query operation variables))
(response (request
url