diff --git a/graphql/cxs-impl/pom.xml b/graphql/cxs-impl/pom.xml index 0a885cef8..e2eaf1ed2 100644 --- a/graphql/cxs-impl/pom.xml +++ b/graphql/cxs-impl/pom.xml @@ -85,12 +85,28 @@ io.github.graphql-java graphql-java-annotations ${graphql.java.annotations.version} + + + com.graphql-java + graphql-java + + + com.graphql-java + graphql-java-extended-scalars + + provided com.graphql-java graphql-java-extended-scalars ${graphql.java.extended.scalars.version} + + + com.graphql-java + graphql-java + + provided 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..99958c233 100644 --- a/graphql/karaf-feature/pom.xml +++ b/graphql/karaf-feature/pom.xml @@ -50,12 +50,12 @@ org.antlr antlr4-runtime - 4.7.1 + ${antlr.runtime.version} com.graphql-java java-dataloader - 2.2.0 + ${java.dataloader.version} org.reactivestreams @@ -78,11 +78,27 @@ io.github.graphql-java graphql-java-annotations ${graphql.java.annotations.version} + + + com.graphql-java + graphql-java-extended-scalars + + + com.graphql-java + graphql-java + + com.graphql-java graphql-java-extended-scalars ${graphql.java.extended.scalars.version} + + + com.graphql-java + graphql-java + + io.reactivex.rxjava2 diff --git a/graphql/karaf-feature/src/main/feature/feature.xml b/graphql/karaf-feature/src/main/feature/feature.xml index b7dbdfb3f..c4c8c90f8 100644 --- a/graphql/karaf-feature/src/main/feature/feature.xml +++ b/graphql/karaf-feature/src/main/feature/feature.xml @@ -31,7 +31,7 @@ wrap:mvn:com.graphql-java/java-dataloader/${java.dataloader.version} mvn:org.reactivestreams/reactive-streams/1.0.2 mvn:com.graphql-java/graphql-java/${graphql.java.version} - mvn:io.github.graphql-java/graphql-java-annotations/${graphql.java.annotations.version} + wrap:mvn:io.github.graphql-java/graphql-java-annotations/${graphql.java.annotations.version} mvn:javax.validation/validation-api/${bean.validation.version} wrap:mvn:com.graphql-java/graphql-java-extended-scalars/${graphql.java.extended.scalars.version} wrap:mvn:com.squareup.okhttp3/okhttp/3.2.0 diff --git a/graphql/pom.xml b/graphql/pom.xml index d71ce84c7..9697de2b2 100644 --- a/graphql/pom.xml +++ b/graphql/pom.xml @@ -31,12 +31,12 @@ pom - 14.0 - 8.0 - 1.0 + 17.2 + 9.1 + 17.1 2.2.19 - 4.7.1 - 2.2.0 + 4.9.2 + 3.1.0 9.4.38.v20210224 diff --git a/samples/graphql-providers-feature/pom.xml b/samples/graphql-providers-feature/pom.xml index b223917a7..f761ffdb9 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-extended-scalars + + + com.graphql-java + graphql-java + + diff --git a/samples/graphql-providers/pom.xml b/samples/graphql-providers/pom.xml index a8437389b..4afec7201 100644 --- a/samples/graphql-providers/pom.xml +++ b/samples/graphql-providers/pom.xml @@ -42,10 +42,32 @@ ${project.version} provided + + com.graphql-java + graphql-java + ${graphql.java.version} + provided + + + com.graphql-java + graphql-java-extended-scalars + ${graphql.java.extended.scalars.version} + provided + io.github.graphql-java graphql-java-annotations ${graphql.java.annotations.version} + + + com.graphql-java + graphql-java-extended-scalars + + + com.graphql-java + graphql-java + + provided diff --git a/samples/pom.xml b/samples/pom.xml index bd88a3bc0..4e826acdc 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -24,7 +24,9 @@ 4.0.0 - 8.0 + 9.1 + 17.1 + 17.2 samples