Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions module/api/graphql/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude

plugins {
id("org.openbase.bco")
id("org.springframework.boot")
Expand All @@ -20,8 +18,8 @@ dependencies {
api(Spring.boot.webflux)
api("org.springframework:spring-webmvc:_")

api( rootProject.files("lib/external/rejoiner-0.5.0-bco.jar"))
api( rootProject.files("lib/external/rejoiner-guice-0.5.0-bco.jar"))
api(rootProject.files("lib/external/rejoiner-0.5.0-bco.jar"))
api(rootProject.files("lib/external/rejoiner-guice-0.5.0-bco.jar"))
// disabled since rejoiner is linked locally.
// api("com.google.api.graphql:rejoiner-guice:_") {
// exclude(group = "com.google.inject", module = "guice")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import graphql.Scalars;
import graphql.execution.instrumentation.Instrumentation;
import graphql.kickstart.execution.context.DefaultGraphQLContext;
import graphql.kickstart.execution.context.GraphQLContext;
import graphql.kickstart.execution.context.GraphQLKickstartContext;
import graphql.kickstart.servlet.context.GraphQLServletContextBuilder;
import graphql.schema.*;
import org.dataloader.DataLoader;
Expand All @@ -58,11 +58,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -78,6 +74,8 @@ public class BcoGraphQlApiSpringBootApplication {
private static Logger LOGGER = LoggerFactory.getLogger(BcoGraphQlApiSpringBootApplication.class);

private final Injector injector;
@Value("${graphql.url:/graphql}")
private String graphqlurl;

{
injector = Guice.createInjector(
Expand All @@ -93,23 +91,6 @@ public class BcoGraphQlApiSpringBootApplication {
);
}

@Value("${graphql.url:/graphql}")
private String graphqlurl;

@Bean
public FilterRegistrationBean<CorsFilter> corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(false);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration(graphqlurl, config);
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
bean.setOrder(0);
return bean;
}

@Bean
GraphQLSchema schema() {
GraphQLSchema schema = injector.getInstance(Key.get(GraphQLSchema.class, Schema.class));
Expand Down Expand Up @@ -264,18 +245,18 @@ public GraphQLServletContextBuilder contextBuilder(DataLoaderRegistry dataLoader
return new GraphQLServletContextBuilder() {

@Override
public GraphQLContext build(HttpServletRequest request, HttpServletResponse response) {
return new DefaultBCOGraphQLContext(dataLoaderRegistry, null, request);
public GraphQLKickstartContext build(HttpServletRequest request, HttpServletResponse response) {
return new DefaultBCOGraphQLContext(dataLoaderRegistry, request);
}

@Override
public GraphQLContext build() {
public GraphQLKickstartContext build() {
return new DefaultGraphQLContext(dataLoaderRegistry, null);
}

@Override
public GraphQLContext build(Session session, HandshakeRequest request) {
return new BCOGraphQLWebsocketContext(dataLoaderRegistry, null, session, request);
public GraphQLKickstartContext build(Session session, HandshakeRequest request) {
return new BCOGraphQLWebsocketContext(dataLoaderRegistry, session, request);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
Expand All @@ -26,14 +26,12 @@
import org.dataloader.DataLoaderRegistry;
import org.openbase.jul.exception.NotAvailableException;

import javax.security.auth.Subject;

public abstract class AbstractBCOGraphQLContext extends DefaultGraphQLContext {

public static final String DATA_LOADER_UNITS = "units";

public AbstractBCOGraphQLContext(DataLoaderRegistry dataLoaderRegistry, Subject subject) {
super(dataLoaderRegistry, subject);
public AbstractBCOGraphQLContext(DataLoaderRegistry dataLoaderRegistry) {
super(dataLoaderRegistry);
}

public abstract String getToken() throws NotAvailableException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
Expand All @@ -26,7 +26,6 @@
import org.dataloader.DataLoaderRegistry;
import org.openbase.jul.exception.NotAvailableException;

import javax.security.auth.Subject;
import javax.websocket.Session;
import javax.websocket.server.HandshakeRequest;
import java.util.Locale;
Expand All @@ -39,8 +38,8 @@ public class BCOGraphQLWebsocketContext extends AbstractBCOGraphQLContext implem
private final String token;
private final String languageCode;

public BCOGraphQLWebsocketContext(DataLoaderRegistry dataLoaderRegistry, Subject subject, Session session, HandshakeRequest handshakeRequest) {
super(dataLoaderRegistry, subject);
public BCOGraphQLWebsocketContext(DataLoaderRegistry dataLoaderRegistry, Session session, HandshakeRequest handshakeRequest) {
super(dataLoaderRegistry);
this.session = session;
this.handshakeRequest = handshakeRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import graphql.kickstart.execution.context.DefaultGraphQLContext;
import org.dataloader.DataLoaderRegistry;
import org.openbase.jul.exception.NotAvailableException;

import javax.security.auth.Subject;
import javax.servlet.http.HttpServletRequest;
import java.util.Locale;

Expand All @@ -35,8 +33,8 @@ public class DefaultBCOGraphQLContext extends AbstractBCOGraphQLContext {
private final String token;
private final String languageCode;

public DefaultBCOGraphQLContext(DataLoaderRegistry dataLoaderRegistry, Subject subject, HttpServletRequest request) {
super(dataLoaderRegistry, subject);
public DefaultBCOGraphQLContext(DataLoaderRegistry dataLoaderRegistry, HttpServletRequest request) {
super(dataLoaderRegistry);
this.token = request.getHeader("Authorization");

final String language = request.getHeader("Accept-Language");
Expand Down
46 changes: 0 additions & 46 deletions module/api/graphql/src/main/resources/application.properties

This file was deleted.

20 changes: 20 additions & 0 deletions module/api/graphql/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server:
port: 13781

spring:
main:
banner-mode: off

graphql:
servlet:
# Sets if GraphQL servlet should be created and exposed. If not specified defaults to "true".
enabled: true
# Sets the path where GraphQL servlet will be exposed. If not specified defaults to "/graphql"
mapping: /graphql
cors-enabled: true
cors:
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
# if you want to @ExceptionHandler annotation for custom GraphQLErrors
exception-handlers-enabled: true
Loading