This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch CAUSEWAY-3676 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit c5b0cb8b2b34a552def276f47f3f43ef657f0d0d Author: danhaywood <[email protected]> AuthorDate: Sun Feb 11 11:29:26 2024 +0000 CAUSEWAY-3676: updates docs --- .../commons/pages/index/collections/Can.adoc | 43 +++++++++++-- .../index/metamodel/tabular/simple/DataTable.adoc | 70 +++++++++++++++++++--- .../applib/marshallers/ScalarMarshaller.adoc | 51 ++++++++++++++++ .../index/graphql/applib/types/TypeMapper.adoc | 27 --------- core/adoc/modules/_overview/pages/about.adoc | 34 +++++++++-- .../pages/sections/causeway.viewer.graphql.adoc | 27 +++++++++ .../core/config/CausewayConfiguration.java | 4 +- .../ROOT/pages/setup-and-configuration.adoc | 14 +++-- .../marshallers/ScalarMarshallerJdk8LocalDate.java | 6 +- .../ScalarMarshallerJdk8ZonedDateTime.java | 6 +- .../marshallers/ScalarMarshallerJodaDateTime.java | 6 +- .../marshallers/ScalarMarshallerJodaLocalDate.java | 6 +- 12 files changed, 230 insertions(+), 64 deletions(-) diff --git a/antora/components/refguide-index/modules/commons/pages/index/collections/Can.adoc b/antora/components/refguide-index/modules/commons/pages/index/collections/Can.adoc index 67ff847b22..6a96281652 100644 --- a/antora/components/refguide-index/modules/commons/pages/index/collections/Can.adoc +++ b/antora/components/refguide-index/modules/commons/pages/index/collections/Can.adoc @@ -16,7 +16,9 @@ Same idiomatic convention applies: References to xref:refguide:commons:index/col ---- interface Can<T> { Optional<T> get(int elementIndex) // <.> + Optional<T> getRelativeToLast(int offset) // <.> T getElseFail(int elementIndex) // <.> + T getRelativeToLastElseFail(int offset) // <.> int compareTo(Can<T> o) // <.> Optional<T> getFirst() // <.> T getFirstElseFail() // <.> @@ -54,6 +56,7 @@ interface Can<T> { Can<T> remove(T element) Can<T> pickByIndex(int... indices) // <.> Can<T> pickByIndex(IntStream intStream) // <.> + Can<T> subCan(int startInclusive) // <.> Can<T> subCan(int startInclusive, int endExclusive) // <.> Can<Can<T>> partitionInnerBound(int maxInnerSize) // <.> Can<Can<T>> partitionOuterBound(int outerSizeYield) // <.> @@ -79,13 +82,23 @@ interface Can<T> { <.> xref:#get_int[get(int)] + -- -Will only ever return an empty Optional, if the elementIndex is out of bounds. +Will (only ever) return an empty _Optional_ , if the elementIndex is out of bounds. +-- +<.> xref:#getRelativeToLast_int[getRelativeToLast(int)] ++ +-- +Shortcut for _get(this.size() - 1 - (-offset))_ -- <.> xref:#getElseFail_int[getElseFail(int)] + -- Shortcut to _get(elementIndex).orElseThrow(...)_ -- +<.> xref:#getRelativeToLastElseFail_int[getRelativeToLastElseFail(int)] ++ +-- +Shortcut for _getElseFail(this.size() - 1 - (-offset))_ +-- <.> xref:#compareTo_Can[compareTo(Can)] + -- @@ -228,10 +241,15 @@ Given _n_ indices, returns an equivalent of(where nulls are being ignored) -- Returns a xref:refguide:commons:index/collections/Can.adoc[Can] that is made of the elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , picked by index using the given _IntStream_ (in the order of picking). -- +<.> xref:#subCan_int[subCan(int)] ++ +-- +Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , starting with indices from _startInclusive_ . +-- <.> xref:#subCan_int_int[subCan(int, int)] + -- -Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , when selected by those indices, that result from given range _endExclusive)_ . +Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , when selected by indices from given range _[startInclusive, endExclusive)_ . -- <.> xref:#partitionInnerBound_int[partitionInnerBound(int)] + @@ -272,7 +290,12 @@ Let _n_ be the number of elements in _other_ . Returns whether the last _n_ elem [#get_int] === get(int) -Will only ever return an empty Optional, if the elementIndex is out of bounds. +Will (only ever) return an empty _Optional_ , if the elementIndex is out of bounds. + +[#getRelativeToLast_int] +=== getRelativeToLast(int) + +Shortcut for _get(this.size() - 1 - (-offset))_ [#getElseFail_int] === getElseFail(int) @@ -281,6 +304,11 @@ Shortcut to _get(elementIndex).orElseThrow(...)_ Will only ever throw, if the elementIndex is out of bounds. +[#getRelativeToLastElseFail_int] +=== getRelativeToLastElseFail(int) + +Shortcut for _getElseFail(this.size() - 1 - (-offset))_ + [#compareTo_Can] === compareTo(Can) @@ -459,10 +487,17 @@ Returns a xref:refguide:commons:index/collections/Can.adoc[Can] that is made of Out of bounds picking is simply ignored. +[#subCan_int] +=== subCan(int) + +Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , starting with indices from _startInclusive_ . + +Out of bounds picking is simply ignored. + [#subCan_int_int] === subCan(int, int) -Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , when selected by those indices, that result from given range _endExclusive)_ . +Returns a sub- xref:refguide:commons:index/collections/Can.adoc[Can] that is made of elements from this xref:refguide:commons:index/collections/Can.adoc[Can] , when selected by indices from given range _[startInclusive, endExclusive)_ . Out of bounds picking is simply ignored. diff --git a/antora/components/refguide-index/modules/core/pages/index/metamodel/tabular/simple/DataTable.adoc b/antora/components/refguide-index/modules/core/pages/index/metamodel/tabular/simple/DataTable.adoc index 0e26c1ee6c..2fc4fa3b55 100644 --- a/antora/components/refguide-index/modules/core/pages/index/metamodel/tabular/simple/DataTable.adoc +++ b/antora/components/refguide-index/modules/core/pages/index/metamodel/tabular/simple/DataTable.adoc @@ -13,27 +13,33 @@ class DataTable { DataTable(ObjectSpecification elementType, Can<? extends ObjectAssociation> dataColumns) // <.> DataTable(ObjectSpecification elementType, String tableFriendlyName, Can<? extends ObjectAssociation> dataColumns, Can<ManagedObject> dataElements) DataTable forDomainType(Class<?> domainType) // <.> - void setDataElements(Can<ManagedObject> dataElements) String getLogicalName() // <.> int getElementCount() // <.> Stream<ManagedObject> streamDataElements() + DataTable addDataElementsFrom(DataTable otherTable) // <.> + DataTable setDataElements(Iterable<ManagedObject> dataElements) // <.> + void setDataElementPojos(Iterable<?> dataElementPojos) // <.> + DataTable populateEntities() // <.> + DataTable populateEntities(Query<?> query) // <.> + DataTable visit(CellVisitor visitor) + DataTable visit(CellVisitor visitor, Predicate<DataColumn> columnFilter) } ---- <.> xref:#DataTable_ObjectSpecification[DataTable(ObjectSpecification)] + -- -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . -- <.> xref:#DataTable_ObjectSpecification_Can[DataTable(ObjectSpecification, Can)] + -- -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . -- <.> xref:#forDomainType_Class[forDomainType(Class)] + -- -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . -- <.> xref:#getLogicalName_[getLogicalName()] + @@ -45,23 +51,48 @@ Unique within application scope, can act as an id. -- Count data rows. -- +<.> xref:#addDataElementsFrom_DataTable[addDataElementsFrom(DataTable)] ++ +-- +Adds all data-elements from the other table to this table. +-- +<.> xref:#setDataElements_Iterable[setDataElements(Iterable)] ++ +-- +Sets the data-elements of this table, which make up the rows of this table. +-- +<.> xref:#setDataElementPojos_Iterable[setDataElementPojos(Iterable)] ++ +-- +Sets the data-elements of this table from given pojos, that are adapted to xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] (s). +-- +<.> xref:#populateEntities_[populateEntities()] ++ +-- +Populates this table from the underlying (default) persistence layer. +-- +<.> xref:#populateEntities_Query[populateEntities(Query)] ++ +-- +Populates this table from the underlying (default) persistence layer, using given xref:refguide:applib:index/query/Query.adoc[Query] to refine the result. +-- == Members [#DataTable_ObjectSpecification] === DataTable(ObjectSpecification) -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . [#DataTable_ObjectSpecification_Can] === DataTable(ObjectSpecification, Can) -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . [#forDomainType_Class] === forDomainType(Class) -Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Can)_ . +Returns an empty xref:refguide:core:index/metamodel/tabular/simple/DataTable.adoc[DataTable] for given domain object type. It can be populated later on using _DataTable#setDataElements(Iterable)_ . [#getLogicalName_] === getLogicalName() @@ -72,3 +103,28 @@ Unique within application scope, can act as an id. === getElementCount() Count data rows. + +[#addDataElementsFrom_DataTable] +=== addDataElementsFrom(DataTable) + +Adds all data-elements from the other table to this table. + +[#setDataElements_Iterable] +=== setDataElements(Iterable) + +Sets the data-elements of this table, which make up the rows of this table. + +[#setDataElementPojos_Iterable] +=== setDataElementPojos(Iterable) + +Sets the data-elements of this table from given pojos, that are adapted to xref:refguide:core:index/metamodel/object/ManagedObject.adoc[ManagedObject] (s). + +[#populateEntities_] +=== populateEntities() + +Populates this table from the underlying (default) persistence layer. + +[#populateEntities_Query] +=== populateEntities(Query) + +Populates this table from the underlying (default) persistence layer, using given xref:refguide:applib:index/query/Query.adoc[Query] to refine the result. diff --git a/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/marshallers/ScalarMarshaller.adoc b/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/marshallers/ScalarMarshaller.adoc new file mode 100644 index 0000000000..e2f30173a5 --- /dev/null +++ b/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/marshallers/ScalarMarshaller.adoc @@ -0,0 +1,51 @@ += ScalarMarshaller +:Notice: 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 ag [...] + +Provides an SPI to allow different scalar datatypes to be marshalled to and from GraphQL scalar types. + +The implementations are called following a chain-of-responsibility pattern, first one matching is used. Use _javax.annotation.Priority_ (with _org.apache.causeway.applib.annotation.PriorityPrecedence_ values) to override the framework-provided defaults, earliest wins. + +== API + +[source,java] +.ScalarMarshaller.java +---- +interface ScalarMarshaller<K> { + boolean handles(Class<?> javaClass) // <.> + GraphQLScalarType getGqlScalarType() // <.> + K unmarshal(Object graphValue, Class<?> targetType) // <.> +} +---- + +<.> xref:#handles_Class[handles(Class)] ++ +-- +Whether this marshaller is able to marshall/unmarshall the provided Java class. +-- +<.> xref:#getGqlScalarType_[getGqlScalarType()] ++ +-- +The corresponding GraphQL scalar type for the Java-class. +-- +<.> xref:#unmarshal_Object_Class[unmarshal(Object, Class)] ++ +-- +Unmarshal the provided graphQL value into its Java equivalent. +-- + +== Members + +[#handles_Class] +=== handles(Class) + +Whether this marshaller is able to marshall/unmarshall the provided Java class. + +[#getGqlScalarType_] +=== getGqlScalarType() + +The corresponding GraphQL scalar type for the Java-class. + +[#unmarshal_Object_Class] +=== unmarshal(Object, Class) + +Unmarshal the provided graphQL value into its Java equivalent. diff --git a/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/types/TypeMapper.adoc b/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/types/TypeMapper.adoc deleted file mode 100644 index 7548ba1a13..0000000000 --- a/antora/components/refguide-index/modules/viewer/pages/index/graphql/applib/types/TypeMapper.adoc +++ /dev/null @@ -1,27 +0,0 @@ -= TypeMapper -:Notice: 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 ag [...] - -SPI to map framework's own datatypes to GraphQL's types. - -The framework provides a default implementation (as a fallback) that supports most of the common data types. - - *NOTE* : this API is considered experimental/beta and may change in the future. - -== API - -[source,java] -.TypeMapper.java ----- -interface TypeMapper { - GraphQLScalarType scalarTypeFor(Class<?> c) - GraphQLOutputType outputTypeFor(OneToOneFeature oneToOneFeature) - GraphQLOutputType outputTypeFor(ObjectSpecification objectSpecification) - GraphQLList listTypeForElementTypeOf(OneToManyAssociation oneToManyAssociation) - GraphQLList listTypeFor(ObjectSpecification elementType) - GraphQLInputType inputTypeFor(OneToOneFeature oneToOneFeature, InputContext inputContext) - GraphQLList inputTypeFor(OneToManyActionParameter oneToManyActionParameter) - GraphQLInputType inputTypeFor(ObjectSpecification elementType) - Object adaptPojo(Object argumentValue, ObjectSpecification elementType) -} ----- - diff --git a/core/adoc/modules/_overview/pages/about.adoc b/core/adoc/modules/_overview/pages/about.adoc index 3a73423f09..be25d52184 100644 --- a/core/adoc/modules/_overview/pages/about.adoc +++ b/core/adoc/modules/_overview/pages/about.adoc @@ -1084,11 +1084,6 @@ Directory: /core/codegen-bytebuddy ---- |Code generation using ByteBuddy. -.Components -**** -o.a.i.core.codegen.bytebuddy.services.ProxyFactoryServiceByteBuddy + -**** - .Dependencies **** net.bytebuddy:byte-buddy:jar:<managed> + @@ -2585,7 +2580,7 @@ org.springframework.graphql:spring-graphql:jar:<managed> + .Document Index Entries **** -xref:refguide:viewer:index/graphql/applib/auth/UserMementoProvider.adoc[UserMementoProvider], xref:refguide:viewer:index/graphql/applib/types/TypeMapper.adoc[TypeMapper] +xref:refguide:viewer:index/graphql/applib/auth/UserMementoProvider.adoc[UserMementoProvider], xref:refguide:viewer:index/graphql/applib/marshallers/ScalarMarshaller.adoc[ScalarMarshaller] **** |Apache Causeway Viewer - GraphQL (Model) @@ -2598,7 +2593,34 @@ Directory: /viewers/graphql/model ---- |.Components **** +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerBigDecimal + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerBigInteger + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerBooleanPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerBooleanWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerBytePrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerByteWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerCharPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerCharacterWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerDoublePrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerDoubleWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerFloatPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerFloatWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerIntPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerIntegerWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerJdk8LocalDate + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerJdk8ZonedDateTime + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerJodaDateTime + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerJodaLocalDate + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerLongPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerLongWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerObject + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerShortPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerShortWrapper + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerString + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerVoidPrimitive + +o.a.i.viewer.graphql.model.marshallers.ScalarMarshallerVoidWrapper + o.a.i.viewer.graphql.model.registry.GraphQLTypeRegistry + +o.a.i.viewer.graphql.model.types.ScalarMapperDefault + **** .Dependencies diff --git a/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc b/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc index a2bb140a8e..b78768d44a 100644 --- a/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc +++ b/core/config/src/main/adoc/modules/config/pages/sections/causeway.viewer.graphql.adoc @@ -38,6 +38,33 @@ authentication.fallback.username | Used as the default username (if not provided by other means). +| +[[causeway.viewer.graphql.lookup.argument]] +causeway.viewer.graphql.lookup. + +argument + +| object +| null + + +| +[[causeway.viewer.graphql.lookup.field-name-prefix]] +causeway.viewer.graphql.lookup. + +field-name-prefix + +| _gqlv_lookup__ +| Lookup field prefix + + +| +[[causeway.viewer.graphql.lookup.field-name-suffix]] +causeway.viewer.graphql.lookup. + +field-name-suffix + +| +| Lookup field suffix + + | [[causeway.viewer.graphql.meta-data.field-name]] causeway.viewer.graphql.meta-data. + diff --git a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java index 507f3a7229..4e3f88f79d 100644 --- a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java +++ b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java @@ -2415,9 +2415,9 @@ public class CausewayConfiguration { private String targetArgName = "_gqlv_target"; } - private final TypeMapper typeMapper = new TypeMapper(); + private final ScalarMarshaller scalarMarshaller = new ScalarMarshaller(); @Data - public static class TypeMapper { + public static class ScalarMarshaller { /** * For both JDK8's {@link java.time.LocalDate} and JodaTime's {@link org.joda.time.LocalDate} diff --git a/viewers/graphql/adoc/modules/ROOT/pages/setup-and-configuration.adoc b/viewers/graphql/adoc/modules/ROOT/pages/setup-and-configuration.adoc index 477a880777..cd95123f12 100644 --- a/viewers/graphql/adoc/modules/ROOT/pages/setup-and-configuration.adoc +++ b/viewers/graphql/adoc/modules/ROOT/pages/setup-and-configuration.adoc @@ -71,20 +71,21 @@ May or may not be used, depending upon the security configuration. -=== TypeMapper +=== ScalarMarshaller -The purpose of the xref:refguide:viewer:index/graphql/applib/types/TypeMapper.adoc[] SPI is to provide an extension point for the marshalling of datatypes. +The purpose of the xref:refguide:viewer:index/graphql/applib/marshallers/ScalarMarshaller.adoc[] SPI is to provide an extension point for the marshalling of scalar values. -The default implementation uses a number of configuration properties: +Each marshaller is responsible for marshalling a given scalar between its Java and GraphQL datatype. +The framework provides a number of default implementations; these use a number of configuration properties: -* xref:refguide:config:sections/causeway.viewer.graphql.adoc#causeway.viewer.graphql.type-mapper.local-date-format[causeway.viewer.graphql.type-mapper.local-date-format]. +* xref:refguide:config:sections/causeway.viewer.graphql.adoc#causeway.viewer.graphql.scalar-marshaller.local-date-format[causeway.viewer.graphql.scalar-marshaller.local-date-format]. + GraphQL does not have a built-in date datatype, and so must be represented as strings. This configuration property define the format of such a string for a local date. + The default for local dates is "yyyy-MM-dd" -* xref:refguide:config:sections/causeway.viewer.graphql.adoc#causeway.viewer.graphql.type-mapper.zoned-date-time-format[causeway.viewer.graphql.type-mapper.zoned-date-time-format] +* xref:refguide:config:sections/causeway.viewer.graphql.adoc#causeway.viewer.graphql.scalar-marshaller.zoned-date-time-format[causeway.viewer.graphql.scalar-marshaller.zoned-date-time-format] + GraphQL does not have a built-in date/time datatype, and so must be represented as strings. This configuration property define the format of such a string for a zoned date time. @@ -92,7 +93,8 @@ This configuration property define the format of such a string for a zoned date The default for a zoned date time is "yyyy-MM-dd HH:mm:ss z". -The default implementation does cover the most common data types, so it may not be necessary to override this implementation; but the option is there if required. +The default implementations can be overridden if necessary by providing an equivalent implementation with an earlier `@Priority`. +Additional scalar datatypes can be supporting by providing additional implementations. diff --git a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8LocalDate.java b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8LocalDate.java index f402a88d59..92146c37e8 100644 --- a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8LocalDate.java +++ b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8LocalDate.java @@ -39,17 +39,17 @@ import org.springframework.stereotype.Component; @Priority(PriorityPrecedence.LATE) public class ScalarMarshallerJdk8LocalDate extends ScalarMarshallerAbstract<LocalDate> { - private final CausewayConfiguration.Viewer.Graphql.TypeMapper typeMapperConfig; + private final CausewayConfiguration.Viewer.Graphql.ScalarMarshaller scalarMarshallerConfig; @Inject public ScalarMarshallerJdk8LocalDate(final CausewayConfiguration causewayConfiguration) { super(LocalDate.class, Scalars.GraphQLString, causewayConfiguration); - typeMapperConfig = causewayConfiguration.getViewer().getGraphql().getTypeMapper(); + scalarMarshallerConfig = causewayConfiguration.getViewer().getGraphql().getScalarMarshaller(); } @Override public LocalDate unmarshal(Object graphValue, Class<?> targetType) { String argumentStr = (String) graphValue; - return LocalDate.parse(argumentStr, DateTimeFormatter.ofPattern(typeMapperConfig.getLocalDateFormat())); + return LocalDate.parse(argumentStr, DateTimeFormatter.ofPattern(scalarMarshallerConfig.getLocalDateFormat())); } } diff --git a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8ZonedDateTime.java b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8ZonedDateTime.java index 2579e9d569..591fbb5fee 100644 --- a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8ZonedDateTime.java +++ b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJdk8ZonedDateTime.java @@ -38,17 +38,17 @@ import org.springframework.stereotype.Component; @Priority(PriorityPrecedence.LATE) public class ScalarMarshallerJdk8ZonedDateTime extends ScalarMarshallerAbstract<ZonedDateTime> { - private final CausewayConfiguration.Viewer.Graphql.TypeMapper typeMapperConfig; + private final CausewayConfiguration.Viewer.Graphql.ScalarMarshaller scalarMarshallerConfig; @Inject public ScalarMarshallerJdk8ZonedDateTime(final CausewayConfiguration causewayConfiguration) { super(ZonedDateTime.class, Scalars.GraphQLString, causewayConfiguration); - typeMapperConfig = causewayConfiguration.getViewer().getGraphql().getTypeMapper(); + scalarMarshallerConfig = causewayConfiguration.getViewer().getGraphql().getScalarMarshaller(); } @Override public ZonedDateTime unmarshal(Object graphValue, Class<?> targetType) { String argumentStr = (String) graphValue; - return ZonedDateTime.parse(argumentStr, DateTimeFormatter.ofPattern(typeMapperConfig.getZonedDateTimeFormat())); + return ZonedDateTime.parse(argumentStr, DateTimeFormatter.ofPattern(scalarMarshallerConfig.getZonedDateTimeFormat())); } } diff --git a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaDateTime.java b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaDateTime.java index f3fa832662..c50b2df9be 100644 --- a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaDateTime.java +++ b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaDateTime.java @@ -37,17 +37,17 @@ import org.springframework.stereotype.Component; @Priority(PriorityPrecedence.LATE) public class ScalarMarshallerJodaDateTime extends ScalarMarshallerAbstract<DateTime> { - private final CausewayConfiguration.Viewer.Graphql.TypeMapper typeMapperConfig; + private final CausewayConfiguration.Viewer.Graphql.ScalarMarshaller scalarMarshallerConfig; @Inject public ScalarMarshallerJodaDateTime(final CausewayConfiguration causewayConfiguration) { super(DateTime.class, Scalars.GraphQLString, causewayConfiguration); - typeMapperConfig = causewayConfiguration.getViewer().getGraphql().getTypeMapper(); + scalarMarshallerConfig = causewayConfiguration.getViewer().getGraphql().getScalarMarshaller(); } @Override public DateTime unmarshal(Object graphValue, Class<?> targetType) { String argumentStr = (String) graphValue; - return DateTime.parse(argumentStr, org.joda.time.format.DateTimeFormat.forPattern(typeMapperConfig.getLocalDateFormat())); + return DateTime.parse(argumentStr, org.joda.time.format.DateTimeFormat.forPattern(scalarMarshallerConfig.getLocalDateFormat())); } } diff --git a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaLocalDate.java b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaLocalDate.java index 2549f28d9a..a1847b1f60 100644 --- a/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaLocalDate.java +++ b/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/marshallers/ScalarMarshallerJodaLocalDate.java @@ -38,17 +38,17 @@ import org.springframework.stereotype.Component; @Priority(PriorityPrecedence.LATE) public class ScalarMarshallerJodaLocalDate extends ScalarMarshallerAbstract<LocalDate> { - private final CausewayConfiguration.Viewer.Graphql.TypeMapper typeMapperConfig; + private final CausewayConfiguration.Viewer.Graphql.ScalarMarshaller scalarMarshallerConfig; @Inject public ScalarMarshallerJodaLocalDate(final CausewayConfiguration causewayConfiguration) { super(LocalDate.class, Scalars.GraphQLString, causewayConfiguration); - typeMapperConfig = causewayConfiguration.getViewer().getGraphql().getTypeMapper(); + scalarMarshallerConfig = causewayConfiguration.getViewer().getGraphql().getScalarMarshaller(); } @Override public LocalDate unmarshal(Object graphValue, Class<?> targetType) { String argumentStr = (String) graphValue; - return LocalDate.parse(argumentStr, org.joda.time.format.DateTimeFormat.forPattern(typeMapperConfig.getLocalDateFormat())); + return LocalDate.parse(argumentStr, org.joda.time.format.DateTimeFormat.forPattern(scalarMarshallerConfig.getLocalDateFormat())); } }
