From a5b5d72400996a3c3cb331cc3edb22baeea9ca74 Mon Sep 17 00:00:00 2001 From: Anatol Sialitski Date: Mon, 26 Dec 2022 12:33:18 +0100 Subject: [PATCH] UNOMI-667: Upgrade GraphQL-Java & other dependencies to the latest versions --- graphql/cxs-impl/pom.xml | 10 ++++ .../converters/UnomiToGraphQLConverter.java | 9 ++-- .../providers/CDPDefaultGraphQLProvider.java | 6 --- .../unomi/graphql/scalars/DateFunction.java | 49 ------------------- .../graphql/scalars/DateTimeFunction.java | 46 ----------------- .../unomi/graphql/scalars/JSONFunction.java | 45 ----------------- .../graphql/schema/PropertyFilterUtils.java | 23 +++++---- .../schema/PropertyValueTypeHelper.java | 13 +++-- graphql/karaf-feature/pom.xml | 12 ++++- graphql/pom.xml | 8 +-- samples/graphql-providers-feature/pom.xml | 10 ++++ samples/graphql-providers/pom.xml | 22 +++++++++ samples/pom.xml | 4 +- 13 files changed, 81 insertions(+), 176 deletions(-) delete mode 100644 graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateFunction.java delete mode 100644 graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateTimeFunction.java delete mode 100644 graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/JSONFunction.java diff --git a/graphql/cxs-impl/pom.xml b/graphql/cxs-impl/pom.xml index 0a885cef8..9853f55f6 100644 --- a/graphql/cxs-impl/pom.xml +++ b/graphql/cxs-impl/pom.xml @@ -86,6 +86,16 @@ graphql-java-annotations ${graphql.java.annotations.version} provided + + + com.graphql-java + graphql-java + + + com.graphql-java + graphql-java-extended-scalars + + com.graphql-java diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/converters/UnomiToGraphQLConverter.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/converters/UnomiToGraphQLConverter.java index 450b30d23..ca3f2e8b4 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/converters/UnomiToGraphQLConverter.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/converters/UnomiToGraphQLConverter.java @@ -18,12 +18,11 @@ package org.apache.unomi.graphql.converters; import graphql.Scalars; +import graphql.scalars.ExtendedScalars; import graphql.schema.GraphQLList; import graphql.schema.GraphQLNonNull; import graphql.schema.GraphQLType; -import org.apache.unomi.graphql.scalars.DateTimeFunction; import org.apache.unomi.graphql.scalars.GeoPointFunction; -import org.apache.unomi.graphql.scalars.JSONFunction; import org.apache.unomi.graphql.schema.PropertyNameTranslator; import org.apache.unomi.graphql.utils.StringUtils; @@ -56,20 +55,20 @@ static GraphQLType convertPropertyType(final String type) { graphQLType = Scalars.GraphQLInt; break; case "long": - graphQLType = Scalars.GraphQLLong; + graphQLType = ExtendedScalars.GraphQLLong; break; case "float": graphQLType = Scalars.GraphQLFloat; break; case "set": case "json": - graphQLType = JSONFunction.JSON_SCALAR; + graphQLType = ExtendedScalars.Json; break; case "geopoint": graphQLType = GeoPointFunction.GEOPOINT_SCALAR; break; case "date": - graphQLType = DateTimeFunction.DATE_TIME_SCALAR; + graphQLType = ExtendedScalars.DateTime; break; case "boolean": graphQLType = Scalars.GraphQLBoolean; diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/providers/CDPDefaultGraphQLProvider.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/providers/CDPDefaultGraphQLProvider.java index 359487dd6..7cb1cd452 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/providers/CDPDefaultGraphQLProvider.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/providers/CDPDefaultGraphQLProvider.java @@ -17,10 +17,7 @@ package org.apache.unomi.graphql.providers; import graphql.annotations.processor.typeFunctions.TypeFunction; -import org.apache.unomi.graphql.scalars.DateFunction; -import org.apache.unomi.graphql.scalars.DateTimeFunction; import org.apache.unomi.graphql.scalars.GeoPointFunction; -import org.apache.unomi.graphql.scalars.JSONFunction; import org.apache.unomi.graphql.types.input.CDPGeoDistanceFilterInput; import org.apache.unomi.graphql.types.input.CDPProfileUpdateEventFilterInput; import org.apache.unomi.graphql.types.input.CDPProfileUpdateEventInput; @@ -87,9 +84,6 @@ public Set> getAdditionalInputTypes() { public Set getTypeFunctions() { final Set typeFunctions = new HashSet<>(); - typeFunctions.add(new DateTimeFunction()); - typeFunctions.add(new DateFunction()); - typeFunctions.add(new JSONFunction()); typeFunctions.add(new GeoPointFunction()); return typeFunctions; diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateFunction.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateFunction.java deleted file mode 100644 index 6b2421257..000000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateFunction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.unomi.graphql.scalars; - -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.annotations.processor.typeFunctions.TypeFunction; -import graphql.scalars.datetime.DateScalar; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; -import java.time.LocalDate; - -public class DateFunction implements TypeFunction { - - public static final DateScalar DATE_SCALAR = new DateScalar(); - - public DateFunction() { - } - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return DATE_SCALAR.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == LocalDate.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return DATE_SCALAR; - } - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateTimeFunction.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateTimeFunction.java deleted file mode 100644 index 2bda2779f..000000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/DateTimeFunction.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.unomi.graphql.scalars; - -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.annotations.processor.typeFunctions.TypeFunction; -import graphql.scalars.datetime.DateTimeScalar; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; -import java.time.OffsetDateTime; - -public class DateTimeFunction implements TypeFunction { - - public static final DateTimeScalar DATE_TIME_SCALAR = new DateTimeScalar(); - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return DATE_TIME_SCALAR.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == OffsetDateTime.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return DATE_TIME_SCALAR; - } - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/JSONFunction.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/JSONFunction.java deleted file mode 100644 index b3590b8c7..000000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/scalars/JSONFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.unomi.graphql.scalars; - -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.annotations.processor.typeFunctions.TypeFunction; -import graphql.scalars.object.JsonScalar; -import graphql.schema.GraphQLType; - -import java.lang.reflect.AnnotatedType; - -public class JSONFunction implements TypeFunction { - - public static final JsonScalar JSON_SCALAR = new JsonScalar(); - - @Override - public String getTypeName(Class aClass, AnnotatedType annotatedType) { - return JSON_SCALAR.getName(); - } - - @Override - public boolean canBuildType(Class aClass, AnnotatedType annotatedType) { - return aClass == Object.class; - } - - @Override - public GraphQLType buildType(boolean input, Class aClass, AnnotatedType annotatedType, ProcessingElementsContainer container) { - return JSON_SCALAR; - } - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java index 49e0741c4..21438a764 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyFilterUtils.java @@ -18,11 +18,10 @@ import graphql.Scalars; import graphql.annotations.processor.GraphQLAnnotations; +import graphql.scalars.ExtendedScalars; import graphql.schema.GraphQLInputObjectField; import graphql.schema.GraphQLInputObjectType; import graphql.schema.GraphQLInputType; -import org.apache.unomi.api.PropertyType; -import org.apache.unomi.graphql.scalars.DateTimeFunction; import org.apache.unomi.graphql.scalars.GeoPointFunction; import org.apache.unomi.graphql.types.input.CDPGeoDistanceFilterInput; import org.apache.unomi.graphql.utils.ReflectionUtil; @@ -74,23 +73,23 @@ private static void addFilters(final List fieldDefiniti } else if ("long".equals(propertyType.getTypeId())) { fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_equals") - .type(Scalars.GraphQLLong) + .type(ExtendedScalars.GraphQLLong) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_lt") - .type(Scalars.GraphQLLong) + .type(ExtendedScalars.GraphQLLong) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_lte") - .type(Scalars.GraphQLLong) + .type(ExtendedScalars.GraphQLLong) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_gt") - .type(Scalars.GraphQLLong) + .type(ExtendedScalars.GraphQLLong) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_gte") - .type(Scalars.GraphQLLong) + .type(ExtendedScalars.GraphQLLong) .build()); } else if ("float".equals(propertyType.getTypeId())) { @@ -117,23 +116,23 @@ private static void addFilters(final List fieldDefiniti } else if ("date".equals(propertyType.getTypeId())) { fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_equals") - .type(DateTimeFunction.DATE_TIME_SCALAR) + .type(ExtendedScalars.DateTime) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_lt") - .type(DateTimeFunction.DATE_TIME_SCALAR) + .type(ExtendedScalars.DateTime) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_lte") - .type(DateTimeFunction.DATE_TIME_SCALAR) + .type(ExtendedScalars.DateTime) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_gt") - .type(DateTimeFunction.DATE_TIME_SCALAR) + .type(ExtendedScalars.DateTime) .build()); fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() .name(propertyName + "_gte") - .type(DateTimeFunction.DATE_TIME_SCALAR) + .type(ExtendedScalars.DateTime) .build()); } else if ("boolean".equals(propertyType.getTypeId())) { fieldDefinitions.add(GraphQLInputObjectField.newInputObjectField() diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyValueTypeHelper.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyValueTypeHelper.java index 797b70df3..b1213cf40 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyValueTypeHelper.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/schema/PropertyValueTypeHelper.java @@ -17,6 +17,7 @@ package org.apache.unomi.graphql.schema; import graphql.Scalars; +import graphql.scalars.ExtendedScalars; import graphql.schema.DataFetchingEnvironment; import graphql.schema.GraphQLInputObjectType; import graphql.schema.GraphQLInputType; @@ -24,8 +25,6 @@ import graphql.schema.GraphQLOutputType; import graphql.schema.GraphQLScalarType; import graphql.schema.GraphQLType; -import org.apache.unomi.graphql.scalars.DateFunction; -import org.apache.unomi.graphql.scalars.DateTimeFunction; public class PropertyValueTypeHelper { @@ -56,13 +55,13 @@ public static String getPropertyValueParameter(final GraphQLType fieldType) { if (Scalars.GraphQLFloat.getName().equals(scalarType.getName()) || Scalars.GraphQLInt.getName().equals(scalarType.getName()) - || Scalars.GraphQLLong.getName().equals(scalarType.getName()) || Scalars.GraphQLFloat.getName().equals(scalarType.getName()) - || Scalars.GraphQLBigDecimal.getName().equals(scalarType.getName()) - || Scalars.GraphQLBigInteger.getName().equals(scalarType.getName())) { + || ExtendedScalars.GraphQLBigDecimal.getName().equals(scalarType.getName()) + || ExtendedScalars.GraphQLLong.getName().equals(scalarType.getName()) + || ExtendedScalars.GraphQLBigInteger.getName().equals(scalarType.getName())) { return "propertyValueInteger"; - } else if (DateTimeFunction.DATE_TIME_SCALAR.getName().equals(scalarType.getName()) - || DateFunction.DATE_SCALAR.getName().equals(scalarType.getName())) { + } else if (ExtendedScalars.DateTime.getName().equals(scalarType.getName()) + || ExtendedScalars.Date.getName().equals(scalarType.getName())) { return "propertyValueDate"; } else { return "propertyValue"; diff --git a/graphql/karaf-feature/pom.xml b/graphql/karaf-feature/pom.xml index 429b3f169..baebbf398 100644 --- a/graphql/karaf-feature/pom.xml +++ b/graphql/karaf-feature/pom.xml @@ -55,7 +55,7 @@ com.graphql-java java-dataloader - 2.2.0 + ${java.dataloader.version} org.reactivestreams @@ -78,6 +78,16 @@ io.github.graphql-java graphql-java-annotations ${graphql.java.annotations.version} + + + com.graphql-java + graphql-java + + + com.graphql-java + graphql-java-extended-scalars + + com.graphql-java diff --git a/graphql/pom.xml b/graphql/pom.xml index d71ce84c7..fcf258486 100644 --- a/graphql/pom.xml +++ b/graphql/pom.xml @@ -31,12 +31,12 @@ pom - 14.0 - 8.0 - 1.0 + 20.0 + 9.1 + 20.0 2.2.19 4.7.1 - 2.2.0 + 3.2.0 9.4.38.v20210224 diff --git a/samples/graphql-providers-feature/pom.xml b/samples/graphql-providers-feature/pom.xml index b223917a7..b64297ab9 100644 --- a/samples/graphql-providers-feature/pom.xml +++ b/samples/graphql-providers-feature/pom.xml @@ -53,6 +53,16 @@ graphql-java-annotations ${graphql.java.annotations.version} compile + + + com.graphql-java + graphql-java + + + com.graphql-java + graphql-java-extended-scalars + + diff --git a/samples/graphql-providers/pom.xml b/samples/graphql-providers/pom.xml index a8437389b..131488262 100644 --- a/samples/graphql-providers/pom.xml +++ b/samples/graphql-providers/pom.xml @@ -42,11 +42,33 @@ ${project.version} provided + + com.graphql-java + graphql-java + ${graphql.java.version} + compile + + + com.graphql-java + graphql-java-extended-scalars + ${graphql.java.extended.scalars.version} + compile + io.github.graphql-java graphql-java-annotations ${graphql.java.annotations.version} provided + + + com.graphql-java + graphql-java + + + com.graphql-java + graphql-java-extended-scalars + + org.osgi diff --git a/samples/pom.xml b/samples/pom.xml index bd88a3bc0..afca3fde0 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -24,7 +24,9 @@ 4.0.0 - 8.0 + 9.1 + 20.0 + 20.0 samples