Skip to content

Commit

Permalink
add basic rootNode query
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 21, 2024
1 parent bae63ea commit cf94adb
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/java/io/cryostat/graphql/GraphQL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright The Cryostat Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cryostat.graphql;

import java.net.URI;

import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.reactive.RestResponse;

@Path("")
public class GraphQL {

@GET
@Path("/api/v2.2/graphql")
@RolesAllowed("write")
public Response redirectGet() throws Exception {
return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
.location(URI.create("/api/v3/graphql"))
.build();
}

@POST
@Path("/api/v2.2/graphql")
@RolesAllowed("write")
public Response redirectPost() throws Exception {
return Response.status(RestResponse.Status.PERMANENT_REDIRECT)
.location(URI.create("/api/v3/graphql"))
.build();
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/cryostat/graphql/RootNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright The Cryostat Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cryostat.graphql;

import io.cryostat.discovery.DiscoveryNode;

import org.eclipse.microprofile.graphql.Description;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;

@GraphQLApi
public class RootNode {

@Query("rootNode")
@Description("Get the root target discovery node")
public DiscoveryNode getRootNode() {
return DiscoveryNode.getUniverse();
}
}
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ quarkus.smallrye-openapi.info-contact-url=https://cryostat.io
quarkus.smallrye-openapi.info-license-name=Apache 2.0
quarkus.smallrye-openapi.info-license-url=https://github.com/cryostatio/cryostat3/blob/main/LICENSE

quarkus.smallrye-graphql.root-path=/api/v3/graphql
quarkus.smallrye-graphql.http.get.enabled=true

quarkus.http.access-log.enabled=true
quarkus.log.category."io.quarkus.http.access-log".level=DEBUG
quarkus.http.enable-compression=true
Expand Down

0 comments on commit cf94adb

Please sign in to comment.