davazp / graphql-mode

An Emacs mode for GraphQL
GNU General Public License v3.0
162 stars 31 forks source link

Write basic README.md file with basic instructions #27

Open davazp opened 5 years ago

hh commented 5 years ago

I'm interested, but having some trouble getting started. Could you put a simple working example of querying github with all the vars set? I've tried the below but get an error when I run control-c control-c:

Wrong type argument: listp, quote
{
  search(query: "project:kubernetes/9", type: ISSUE, first: 1, after: null) {
    issueCount
  }
}
# Local Variables:
# graphql-extra-headers: '(("Authorization" . "bearer MYTOKEN"))
# graphql-url: "https://api.github.com/graphql"
# graphql-variables-file: "graphql-variables"
# End:
hh commented 5 years ago
Debugger entered--Lisp error: (wrong-type-argument listp quote)
  request--curl-command("https://api.github.com/graphql" :files* nil :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #5) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7")) :complete #f(compiled-function (&rest _) #<bytecode 0x260c7cd>) :type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #25) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7")))
  apply(request--curl-command "https://api.github.com/graphql" :files* nil :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #6) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7")) (:complete #f(compiled-function (&rest _) #<bytecode 0x260c7cd>) :type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #27) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7"))))
  request--curl("https://api.github.com/graphql" :complete #f(compiled-function (&rest _) #<bytecode 0x260c7cd>) :type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #21) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7")))
  apply(request--curl "https://api.github.com/graphql" :complete #f(compiled-function (&rest _) #<bytecode 0x260c7cd>) (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #23) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7"))))
  request--curl-sync("https://api.github.com/graphql" :type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #19) :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7")))
  apply(request--curl-sync "https://api.github.com/graphql" (:type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>) :error #f(compiled-function (&rest args2) #<bytecode 0x260c7b5>) :url "https://api.github.com/graphql" :response #s(request-response :status-code nil :history nil :data nil :error-thrown nil :symbol-status nil :url "https://api.github.com/graphql" :done-p nil :settings #3 :-buffer nil :-raw-header nil :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-request72yAF7"))))
  request("https://api.github.com/graphql" :type "POST" :data "{\"query\":\"{\\n  search(query: \\\"project:kubernetes/9\\\", type: ISSUE, first: 100, after: null) {\\n    issueCount\\n  }\\n}\\n# Local Variables:\\n# graphql-extra-headers: '((\\\"Authorization\\\" . \\\"bearer MYTOKEN\\\"))\\n# graphql-url: \\\"https://api.github.com/graphql\\\"\\n# graphql-variables-file: \\\"graphql-variables\\\"\\n# End:\\n\\n\"}" :headers (("Content-Type" . "application/json") quote (("Authorization" . "bearer MYTOKEN"))) :parser json-read :sync t :complete #f(compiled-function (&rest _) #<bytecode 0x260c775>))
  graphql-post-request("https://api.github.com/graphql" "{\n  search(query: \"project:kubernetes/9\", type: ISSUE, first: 100, after: null) {\n    issueCount\n  }\n}\n# Local Variables:\n# graphql-extra-headers: '((\"Authorization\" . \"bearer MYTOKEN\"))\n# graphql-url: \"https://api.github.com/graphql\"\n# graphql-variables-file: \"graphql-variables\"\n# End:\n\n" nil nil)
  graphql--query("{\n  search(query: \"project:kubernetes/9\", type: ISSUE, first: 100, after: null) {\n    issueCount\n  }\n}\n# Local Variables:\n# graphql-extra-headers: '((\"Authorization\" . \"bearer MYTOKEN\"))\n# graphql-url: \"https://api.github.com/graphql\"\n# graphql-variables-file: \"graphql-variables\"\n# End:\n\n" nil nil)
  graphql-send-query()
  funcall-interactively(graphql-send-query)
  call-interactively(graphql-send-query nil nil)
  command-execute(graphql-send-query)
davazp commented 5 years ago

I think the error is caused by the extra quote in the file variable

# graphql-extra-headers: '(("Authorization" . "bearer MYTOKEN"))

Try removing the '.

hh commented 5 years ago

That fixed it the example. Thanks.

hh commented 5 years ago

How might we go about inspecting the curl input / output? It look like 'request-response--raw-header' is returning nil for me.

         (request-response--raw-header response)
         ;; (message response)
         (insert "\n\n"
                 (propertize (request-response--raw-header response)
                             'face 'font-lock-comment-face
                             'font-lock-face 'font-lock-comment-face)))))
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  propertize(nil face font-lock-comment-face font-lock-face font-lock-comment-face)
  (insert "\n\n" (propertize (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 10)) (quote face) (quote font-lock-comment-face) (quote font-lock-face) (quote font-lock-comment-face)))
  (progn (erase-buffer) (insert (json-encode (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 3)))) (json-pretty-print-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 10)) (insert "\n\n" (propertize (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 10)) (quote face) (quote font-lock-comment-face) (quote font-lock-face) (quote font-lock-comment-face))))
  (setq value (progn (erase-buffer) (insert (json-encode (progn (or (and (memq ... cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list ... response))) (aref response 3)))) (json-pretty-print-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 10)) (insert "\n\n" (propertize (progn (or (and (memq ... cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list ... response))) (aref response 10)) (quote face) (quote font-lock-comment-face) (q(declare-function request-response--raw-header "request")
uote font-lock-face) (quote font-lock-comment-face)))))
  (save-current-buffer (set-buffer buffer) (setq value (progn (erase-buffer) (insert (json-encode (progn (or (and ... t) (signal ... ...)) (aref response 3)))) (json-pretty-print-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or (and (memq (type-of response) cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list (quote request-response) response))) (aref response 10)) (insert "\n\n" (propertize (progn (or (and ... t) (signal ... ...)) (aref response 10)) (quote face) (quote font-lock-comment-face) (quote font-lock-face) (quote font-lock-comment-face))))) (setq window (temp-buffer-window-show buffer (quote display-buffer-pop-up-window))))
  (let* ((buffer (temp-buffer-window-setup "*GraphQL*")) (standard-output buffer) window value) (save-current-buffer (set-buffer buffer) (setq value (progn (erase-buffer) (insert (json-encode (progn (or ... ...) (aref response 3)))) (json-pretty-print-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or (and (memq ... cl-struct-request-response-tags) t) (signal (quote wrong-type-argument) (list ... response))) (aref response 10)) (insert "\n\n" (propertize (progn (or ... ...) (aref response 10)) (quote face) (quote font-lock-comment-face) (quote font-lock-face) (quote font-lock-comment-face))))) (setq window (temp-buffer-window-show buffer (quote display-buffer-pop-up-window)))) (if (functionp nil) (funcall nil window value) value))
  (let* ((query (buffer-substring-no-properties (point-min) (point-max))) (operation (graphql-current-operation)) (variables (graphql-current-variables var)) (response (graphql--query query operation variables))) (let* ((buffer (temp-buffer-window-setup "*GraphQL*")) (standard-output buffer) window value) (save-current-buffer (set-buffer buffer) (setq value (progn (erase-buffer) (insert (json-encode (progn ... ...))) (json-pretty-print-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or (and ... t) (signal ... ...)) (aref response 10)) (insert "\n\n" (propertize (progn ... ...) (quote face) (quote font-lock-comment-face) (quote font-lock-face) (quote font-lock-comment-face))))) (setq window (temp-buffer-window-show buffer (quote display-buffer-pop-up-window)))) (if (functionp nil) (funcall nil window value) value)))
  (let ((graphql-url url) (graphql-variables-file var)) (let* ((query (buffer-substring-no-properties (point-min) (point-max))) (operation (graphql-current-operation)) (variables (graphql-current-variables var)) (response (graphql--query query operation variables))) (let* ((buffer (temp-buffer-window-setup "*GraphQL*")) (standard-output buffer) window value) (save-current-buffer (set-buffer buffer) (setq value (progn (erase-buffer) (insert (json-encode ...)) (json-pretty-pri(declare-function request-response--raw-header "request")
nt-buffer) (goto-char (point-max)) (message "XXXXXXXX") (progn (or ... ...) (aref response 10)) (insert "\n\n" (propertize ... ... ... ... ...)))) (setq window (temp-buffer-window-show buffer (quote display-buffer-pop-up-window)))) (if (functionp nil) (funcall nil window value) value))))
  (let* ((url (or graphql-url (read-string "GraphQL URL: "))) (var (or graphql-variables-file (read-file-name "GraphQL Variables: ")))) (let ((graphql-url url) (graphql-variables-file var)) (let* ((query (buffer-substring-no-properties (point-min) (point-max))) (operation (graphql-current-operation)) (variables (graphql-current-variables var)) (response (graphql--query query operation variables))) (let* ((buffer (temp-buffer-window-setup "*GraphQL*")) (standard-output buffer) window value) (save-current-buffer (set-buffer buffer) (setq value (progn (erase-buffer) (insert ...) (json-pretty-print-buffer) (goto-char ...) (message "XXXXXXXX") (progn ... ...) (insert "\n\n" ...))) (setq window (temp-buffer-window-show buffer (quote display-buffer-pop-up-window)))) (if (functionp nil) (funcall nil window value) value)))) (setq graphql-url url) (setq graphql-variables-file var) nil)
  graphql-send-query()
  funcall-interactively(graphql-send-query)
  call-interactively(graphql-send-query nil nil)
  command-execute(graphql-send-query)