File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1285,6 +1285,7 @@ protected GHUser getUser(GHUser orig) {
12851285 @ Nonnull
12861286 Requester createGraphQLRequest (String query ) {
12871287 return createRequest ().method ("POST" )
1288+ .withApiUrl (getApiUrl ().replace ("/api/v3" , "/api" ))
12881289 .rateLimit (RateLimitTarget .GRAPHQL )
12891290 .with ("query" , query )
12901291 .withUrlPath ("/graphql" );
Original file line number Diff line number Diff line change @@ -207,6 +207,35 @@ public void testGitHubBuilderFromEnvironment() throws IOException {
207207
208208 }
209209
210+ /**
211+ * Test that GitHub.com GraphQL URL is correctly constructed.
212+ *
213+ * @throws Exception
214+ * the exception
215+ */
216+ @ Test
217+ public void testGitHubCloudGraphQLUrl () throws Exception {
218+ GitHub hub = GitHub .connect ("bogus" , "bogus" );
219+ GitHubRequest request = hub .createGraphQLRequest ("test query" ).build ();
220+ assertThat (request .url ().toString (), equalTo ("https://api.github.com/graphql" ));
221+ }
222+
223+ /**
224+ * Test that GitHub Enterprise GraphQL URL is correctly constructed.
225+ * <p>
226+ * GitHub Enterprise Server has REST API at /api/v3 but GraphQL at /api/graphql.
227+ * </p>
228+ *
229+ * @throws Exception
230+ * the exception
231+ */
232+ @ Test
233+ public void testGitHubEnterpriseGraphQLUrl () throws Exception {
234+ GitHub hub = GitHub .connectToEnterpriseWithOAuth ("https://enterprise.kohsuke.org/api/v3" , "bogus" , "bogus" );
235+ GitHubRequest request = hub .createGraphQLRequest ("test query" ).build ();
236+ assertThat (request .url ().toString (), equalTo ("https://enterprise.kohsuke.org/api/graphql" ));
237+ }
238+
210239 /**
211240 * Test git hub is api url valid.
212241 *
You can’t perform that action at this time.
0 commit comments