You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by as...@apache.org on 2022/12/26 11:33:46 UTC

[unomi] 01/01: UNOMI-667: Upgrade GraphQL-Java & other dependencies to the latest versions

This is an automated email from the ASF dual-hosted git repository.

asi pushed a commit to branch UNOMI-667
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 53deebb239f4633cb1cb2498b92cec47c01b08e6
Author: Anatol Sialitski <as...@enonic.com>
AuthorDate: Mon Dec 26 12:33:18 2022 +0100

    UNOMI-667: Upgrade GraphQL-Java & other dependencies to the latest versions
---
 .../converters/UnomiToGraphQLConverter.java        |  9 ++--
 .../providers/CDPDefaultGraphQLProvider.java       |  6 ---
 .../apache/unomi/graphql/scalars/DateFunction.java | 49 ----------------------
 .../unomi/graphql/scalars/DateTimeFunction.java    | 46 --------------------
 .../apache/unomi/graphql/scalars/JSONFunction.java | 45 --------------------
 .../unomi/graphql/schema/PropertyFilterUtils.java  | 23 +++++-----
 .../graphql/schema/PropertyValueTypeHelper.java    | 13 +++---
 graphql/pom.xml                                    |  6 +--
 8 files changed, 24 insertions(+), 173 deletions(-)

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 @@ public interface UnomiToGraphQLConverter {
                 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 class CDPDefaultGraphQLProvider
     public Set<TypeFunction> getTypeFunctions() {
         final Set<TypeFunction> 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 @@ package org.apache.unomi.graphql.schema;
 
 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 @@ public class PropertyFilterUtils {
         } 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 @@ public class PropertyFilterUtils {
         } 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.GraphQLObjectType;
 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 class PropertyValueTypeHelper {
 
         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/pom.xml b/graphql/pom.xml
index d71ce84c7..51afed4b3 100644
--- a/graphql/pom.xml
+++ b/graphql/pom.xml
@@ -31,9 +31,9 @@
     <packaging>pom</packaging>
 
     <properties>
-        <graphql.java.version>14.0</graphql.java.version>
-        <graphql.java.annotations.version>8.0</graphql.java.annotations.version>
-        <graphql.java.extended.scalars.version>1.0</graphql.java.extended.scalars.version>
+        <graphql.java.version>20.0</graphql.java.version>
+        <graphql.java.annotations.version>9.1</graphql.java.annotations.version>
+        <graphql.java.extended.scalars.version>20.0</graphql.java.extended.scalars.version>
         <reactivex.version>2.2.19</reactivex.version>
         <antlr.runtime.version>4.7.1</antlr.runtime.version>
         <java.dataloader.version>2.2.0</java.dataloader.version>