Skip to content

Commit d139e9e

Browse files
committed
Use forge token for graphql mutations
Closes #782.
1 parent 7454f16 commit d139e9e

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

lisp/forge-github.el

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@
712712

713713
(cl-defmethod forge--submit-create-discussion ((_ forge-github-repository) repo)
714714
(pcase-let ((`(,title . ,body) (forge--post-buffer-text)))
715-
(ghub--graphql
715+
(forge--graphql
716716
'(mutation (createDiscussion
717717
[(input $input CreateDiscussionInput!)]
718718
clientMutationId))
@@ -864,13 +864,13 @@
864864
state)
865865
(with-slots (their-id) topic
866866
(cond ((eq state 'open)
867-
(ghub--graphql
867+
(forge--graphql
868868
'(mutation (reopenDiscussion
869869
[(input $input ReopenDiscussionInput!)]
870870
clientMutationId))
871871
`((input (discussionId . ,their-id)))
872872
:callback (forge--set-field-callback topic t)))
873-
((ghub--graphql
873+
((forge--graphql
874874
'(mutation (closeDiscussion
875875
[(input $input CloseDiscussionInput!)]
876876
clientMutationId))
@@ -905,7 +905,7 @@
905905
((_repo forge-github-repository)
906906
(topic forge-discussion)
907907
category)
908-
(ghub--graphql
908+
(forge--graphql
909909
'(mutation (updateDiscussion
910910
[(input $input UpdateDiscussionInput!)]
911911
clientMutationId))
@@ -926,7 +926,7 @@
926926
(let* ((old (oref topic answer))
927927
(old (and old (forge--their-id old)))
928928
(new (and answer (oref answer their-id))))
929-
(ghub--graphql
929+
(forge--graphql
930930
`(mutation
931931
,@(and old '((unmarkDiscussionCommentAsAnswer
932932
[(input $old UnmarkDiscussionCommentAsAnswerInput!)]
@@ -965,7 +965,7 @@
965965
(add (cl-set-difference new old :test #'equal))
966966
(del (cl-set-difference old new :test #'equal)))
967967
(when (or add del)
968-
(ghub--graphql
968+
(forge--graphql
969969
`(mutation
970970
,@(and add '((addLabelsToLabelable
971971
[(input $add AddLabelsToLabelableInput!)]
@@ -991,7 +991,7 @@
991991
(add (cl-set-difference new old :test #'equal))
992992
(del (cl-set-difference old new :test #'equal)))
993993
(when (or add del)
994-
(ghub--graphql
994+
(forge--graphql
995995
`(mutation
996996
,@(and add '((addAssigneesToAssignable
997997
[(input $add AddAssigneesToAssignableInput!)]
@@ -1014,7 +1014,7 @@
10141014
(oref repo id)
10151015
(vconcat (seq-remove (##string-match "/" %) reviewers))))
10161016
(teams nil)) ;TODO Investigate #742, track id, then use it here.
1017-
(ghub--graphql
1017+
(forge--graphql
10181018
`(mutation (requestReviews
10191019
[(input $input RequestReviewsInput!)]
10201020
clientMutationId))

lisp/forge-gitlab.el

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,20 @@
674674
:callback callback
675675
:errorback (or errorback (and callback t))))
676676

677+
(cl-defun forge--graphql (graphql
678+
&optional variables
679+
&key username host forge
680+
headers
681+
callback errorback)
682+
(let ((ghub-graphql-message-progress nil))
683+
(ghub--graphql-vacuum graphql variables callback nil
684+
:username username
685+
:auth 'forge
686+
:host host
687+
:forge forge
688+
:headers headers
689+
:errorback errorback)))
690+
677691
;;; _
678692
;; Local Variables:
679693
;; read-symbol-shorthands: (

0 commit comments

Comments
 (0)