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 0d0ae4897e51e9bc9dafd3735db67dc1cbaa1472
Author: danhaywood <[email protected]>
AuthorDate: Sun Jan 21 16:33:04 2024 +0000

    CAUSEWAY-3676: still not able to have actions under mutations ...
---
 .../viewer/graphql/model/domain/GqlvAction.java    |   5 +-
 .../graphql/model/domain/GqlvDomainObject.java     |  20 ++--
 .../graphql/model/domain/GqlvDomainService.java    |  32 +++---
 .../viewer/graphql/model/domain/GqlvMutations.java |   4 +-
 .../graphql/model/domain/GqlvMutationsHolder.java  |   4 +
 .../e2e/Domain_IntegTest.create_department._.gql   |   2 +
 .../test/e2e/Schema_IntegTest.schema.approved.json | 121 +++++++++++++++++++++
 .../graphql/test/src/test/resources/schema.gql     |  11 ++
 .../integration/GraphQlSourceForCauseway.java      |  11 +-
 9 files changed, 177 insertions(+), 33 deletions(-)

diff --git 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvAction.java
 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvAction.java
index d518b8bffd..f5bfbc4d40 100644
--- 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvAction.java
+++ 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvAction.java
@@ -55,8 +55,10 @@ public class GqlvAction extends GqlvMember<ObjectAction, 
GqlvActionHolder> {
     }
 
     public void addDataFetcher() {
+        GraphQLObjectType gqlObjectType = getHolder().getGqlObjectType();
+        GraphQLFieldDefinition fieldDefinition = getFieldDefinition();
         codeRegistryBuilder.dataFetcher(
-                FieldCoordinates.coordinates(getHolder().getGqlObjectType(), 
getFieldDefinition()),
+                FieldCoordinates.coordinates(gqlObjectType, fieldDefinition),
                 this::invoke
         );
     }
@@ -65,6 +67,7 @@ public class GqlvAction extends GqlvMember<ObjectAction, 
GqlvActionHolder> {
             final DataFetchingEnvironment dataFetchingEnvironment) {
         final ObjectAction objectAction = getObjectAction();
 
+        // TODO: this assumes that the dataFetchingEnvironment is a domain 
object, but in fact it could be a 'mutations' object.
         Object domainObjectInstance = dataFetchingEnvironment.getSource();
 
         Class<?> domainObjectInstanceClass = domainObjectInstance.getClass();
diff --git 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainObject.java
 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainObject.java
index dc7b76da12..d8e8b03087 100644
--- 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainObject.java
+++ 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainObject.java
@@ -248,6 +248,10 @@ public class GqlvDomainObject implements GqlvActionHolder, 
GqlvPropertyHolder, G
         return mutations.buildMutationsTypeAndFieldIfRequired();
     }
 
+    @Override
+    public void addMutationsField(GraphQLFieldDefinition mutationsField) {
+        gqlObjectTypeBuilder.field(mutationsField);
+    }
 
     public void addDataFetchersForMeta() {
         meta.addDataFetchers();
@@ -270,17 +274,6 @@ public class GqlvDomainObject implements GqlvActionHolder, 
GqlvPropertyHolder, G
     }
 
 
-    GraphQLObjectType createAndRegisterMutatorsType(
-            final Set<GraphQLType> graphQLObjectTypes) {
-
-        //TODO: this is not going to work, because we need to dynamically add 
fields
-        String mutatorsTypeName = getLogicalTypeNameSanitized() + 
"__DomainObject_mutators";
-        GraphQLObjectType.Builder mutatorsTypeBuilder = 
newObject().name(mutatorsTypeName);
-        GraphQLObjectType mutatorsType = mutatorsTypeBuilder.build();
-        graphQLObjectTypes.add(mutatorsType);
-        return mutatorsType;
-    }
-
     public void registerTypesInto(GraphQLTypeRegistry graphQLTypeRegistry) {
 
         GraphQLObjectType graphQLObjectType = buildGqlObjectType();
@@ -292,4 +285,9 @@ public class GqlvDomainObject implements GqlvActionHolder, 
GqlvPropertyHolder, G
         
getMutationsTypeIfAny().ifPresent(graphQLTypeRegistry::addTypeIfNotAlreadyPresent);
     }
 
+    @Override
+    public String toString() {
+        return objectSpecification.getLogicalTypeName();
+    }
+
 }
diff --git 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainService.java
 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainService.java
index 06b6210098..2808ca70a2 100644
--- 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainService.java
+++ 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvDomainService.java
@@ -88,15 +88,7 @@ public class GqlvDomainService implements GqlvActionHolder, 
GqlvMutationsHolder
                     addAction(objectAction);
                 });
 
-        buildMutatorsTypeIfRequired();
-//        Optional<GraphQLObjectType> mutatorsTypeIfAny = 
buildMutationsTypeAndFieldIfRequired();
-//        mutatorsTypeIfAny.ifPresent(mutatorsType -> {
-//            GraphQLFieldDefinition gql_mutations = newFieldDefinition()
-//                    .name(_Constants.GQL_MUTATIONS_FIELDNAME)
-//                    .type(mutatorsType)
-//                    .build();
-//            gqlObjectTypeBuilder.field(gql_mutations);
-//        });
+        buildMutationsTypeAndFieldIfRequired();
 
         return anyActions.get();
     }
@@ -105,8 +97,10 @@ public class GqlvDomainService implements GqlvActionHolder, 
GqlvMutationsHolder
         if (objectAction.getSemantics().isSafeInNature()) {
             safeActions.add(new GqlvAction(this, objectAction, 
gqlObjectTypeBuilder, codeRegistryBuilder));
         } else {
-             // TODO: should register with mutators instead ...
-//            mutators.addAction(objectAction);
+            // TODO: still trying to add the action to the mutations
+//             mutations.addAction(objectAction);
+
+            // for now, we go direct...
             safeActions.add(new GqlvAction(this, objectAction, 
gqlObjectTypeBuilder, codeRegistryBuilder));
         }
     }
@@ -137,7 +131,7 @@ public class GqlvDomainService implements GqlvActionHolder, 
GqlvMutationsHolder
 
 
     /**
-     * @see #buildMutatorsTypeIfRequired()
+     * @see #buildMutationsTypeAndFieldIfRequired()
      */
     public Optional<GraphQLObjectType> getMutatorsTypeIfAny() {
         return mutations.getMutationsTypeIfAny();
@@ -146,10 +140,14 @@ public class GqlvDomainService implements 
GqlvActionHolder, GqlvMutationsHolder
     /**
      * @see #getMutatorsTypeIfAny()
      */
-    public Optional<GraphQLObjectType> buildMutatorsTypeIfRequired() {
+    public Optional<GraphQLObjectType> buildMutationsTypeAndFieldIfRequired() {
         return mutations.buildMutationsTypeAndFieldIfRequired();
     }
 
+    @Override
+    public void addMutationsField(GraphQLFieldDefinition mutationsField) {
+        gqlObjectTypeBuilder.field(mutationsField);
+    }
 
     public GraphQLFieldDefinition createTopLevelQueryField() {
         return newFieldDefinition()
@@ -162,8 +160,7 @@ public class GqlvDomainService implements GqlvActionHolder, 
GqlvMutationsHolder
 
     public void registerTypesInto(GraphQLTypeRegistry graphQLTypeRegistry) {
 
-        GraphQLObjectType graphQLObjectType = buildGqlObjectType();
-        //graphQLTypeRegistry.addTypeIfNotAlreadyPresent(graphQLObjectType);
+        buildGqlObjectType();
 
         
getMutatorsTypeIfAny().ifPresent(graphQLTypeRegistry::addTypeIfNotAlreadyPresent);
     }
@@ -176,4 +173,9 @@ public class GqlvDomainService implements GqlvActionHolder, 
GqlvMutationsHolder
         getMutations().addDataFetchers();
     }
 
+    @Override
+    public String toString() {
+        return objectSpecification.getLogicalTypeName();
+    }
+
 }
diff --git 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutations.java
 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutations.java
index e27b734c92..4495616a9c 100644
--- 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutations.java
+++ 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutations.java
@@ -13,7 +13,6 @@ import java.util.List;
 import java.util.Optional;
 
 import org.apache.causeway.applib.services.bookmark.BookmarkService;
-import org.apache.causeway.applib.services.metamodel.BeanSort;
 import org.apache.causeway.core.metamodel.objectmanager.ObjectManager;
 import org.apache.causeway.core.metamodel.spec.feature.ObjectAction;
 import org.apache.causeway.viewer.graphql.model.types._Constants;
@@ -92,6 +91,7 @@ public class GqlvMutations implements GqlvActionHolder {
         if (mutationsTypeIfAny != null) {
             throw new IllegalArgumentException("Gql mutations type and field 
has already been built for " + 
holder.getObjectSpecification().getLogicalTypeName());
         }
+
         if (hasActions()) {
 
             // create the type
@@ -106,7 +106,7 @@ public class GqlvMutations implements GqlvActionHolder {
             mutationsFieldIfAny = Optional.of(mutationsField);
 
             // register the field into the owning type
-            gqlObjectTypeBuilder.field(mutationsField);
+            holder.addMutationsField(mutationsField);
 
         } else {
             mutationsFieldIfAny = Optional.empty();
diff --git 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutationsHolder.java
 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutationsHolder.java
index a8caa067c9..11fde563d2 100644
--- 
a/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutationsHolder.java
+++ 
b/incubator/viewers/graphql/model/src/main/java/org/apache/causeway/viewer/graphql/model/domain/GqlvMutationsHolder.java
@@ -1,5 +1,7 @@
 package org.apache.causeway.viewer.graphql.model.domain;
 
+import graphql.schema.GraphQLFieldDefinition;
+
 import org.apache.causeway.core.metamodel.spec.ObjectSpecification;
 
 /**
@@ -7,4 +9,6 @@ import 
org.apache.causeway.core.metamodel.spec.ObjectSpecification;
  */
 public interface GqlvMutationsHolder {
     ObjectSpecification getObjectSpecification();
+
+    void addMutationsField(GraphQLFieldDefinition mutationsField);
 }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.create_department._.gql
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.create_department._.gql
index f9f5a62d19..a53f71011e 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.create_department._.gql
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Domain_IntegTest.create_department._.gql
@@ -3,5 +3,7 @@
         createDepartment(name: "newbie") {
             name
         }
+#        _gql_mutations {
+#        }
     }
 }
diff --git 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
index fd611a8a3e..48597cbcc3 100644
--- 
a/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
+++ 
b/incubator/viewers/graphql/test/src/test/java/org/apache/causeway/viewer/graphql/viewer/test/e2e/Schema_IntegTest.schema.approved.json
@@ -1364,6 +1364,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "causeway_applib_PropertyNode__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -1959,6 +1970,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "causeway_applib_node_ActionNode__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -2105,6 +2127,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "causeway_applib_node_CollectionNode__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -4833,6 +4866,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_commons_functional_Either__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -5097,6 +5141,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_commons_functional_Railway__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -5307,6 +5362,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_commons_functional_ThrowingConsumer__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -5445,6 +5511,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_commons_functional_ThrowingFunction__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -5607,6 +5684,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_commons_functional_ThrowingRunnable__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -5782,6 +5870,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "org_apache_causeway_commons_functional_Try__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -6450,6 +6549,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : 
"org_apache_causeway_core_metamodel_inspect_model_MemberNode__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
@@ -6859,6 +6969,17 @@
           },
           "isDeprecated" : false,
           "deprecationReason" : null
+        }, {
+          "name" : "_gql_mutations",
+          "description" : null,
+          "args" : [ ],
+          "type" : {
+            "kind" : "OBJECT",
+            "name" : "university_dept_DeptHead__mutations",
+            "ofType" : null
+          },
+          "isDeprecated" : false,
+          "deprecationReason" : null
         } ],
         "inputFields" : null,
         "interfaces" : [ ],
diff --git a/incubator/viewers/graphql/test/src/test/resources/schema.gql 
b/incubator/viewers/graphql/test/src/test/resources/schema.gql
index 25cdac1a1c..0bbeabb0c6 100644
--- a/incubator/viewers/graphql/test/src/test/resources/schema.gql
+++ b/incubator/viewers/graphql/test/src/test/resources/schema.gql
@@ -68,6 +68,7 @@ type causeway_applib_ParameterNode__meta {
 
 type causeway_applib_PropertyNode {
   _gql_meta: causeway_applib_PropertyNode__meta
+  _gql_mutations: causeway_applib_PropertyNode__mutations
   mixedIn: String!
   parentNode: causeway_applib_TypeNode!
   property: String!
@@ -129,6 +130,7 @@ type causeway_applib_UserMenu {
 
 type causeway_applib_node_ActionNode {
   _gql_meta: causeway_applib_node_ActionNode__meta
+  _gql_mutations: causeway_applib_node_ActionNode__mutations
   action: String!
   mixedIn: String!
   parentNode: causeway_applib_TypeNode!
@@ -145,6 +147,7 @@ type causeway_applib_node_ActionNode__mutations {
 
 type causeway_applib_node_CollectionNode {
   _gql_meta: causeway_applib_node_CollectionNode__meta
+  _gql_mutations: causeway_applib_node_CollectionNode__mutations
   collection: String!
   mixedIn: String!
   parentNode: causeway_applib_TypeNode!
@@ -420,6 +423,7 @@ type java_util_stream_Stream__meta {
 
 type org_apache_causeway_commons_functional_Either {
   _gql_meta: org_apache_causeway_commons_functional_Either__meta
+  _gql_mutations: org_apache_causeway_commons_functional_Either__mutations
   left: String!
   right: String!
 }
@@ -440,6 +444,7 @@ type 
org_apache_causeway_commons_functional_Either__mutations {
 
 type org_apache_causeway_commons_functional_Railway {
   _gql_meta: org_apache_causeway_commons_functional_Railway__meta
+  _gql_mutations: org_apache_causeway_commons_functional_Railway__mutations
   failure: String!
   success: String!
 }
@@ -459,6 +464,7 @@ type 
org_apache_causeway_commons_functional_Railway__mutations {
 
 type org_apache_causeway_commons_functional_ThrowingConsumer {
   _gql_meta: org_apache_causeway_commons_functional_ThrowingConsumer__meta
+  _gql_mutations: 
org_apache_causeway_commons_functional_ThrowingConsumer__mutations
 }
 
 type org_apache_causeway_commons_functional_ThrowingConsumer__meta {
@@ -473,6 +479,7 @@ type 
org_apache_causeway_commons_functional_ThrowingConsumer__mutations {
 
 type org_apache_causeway_commons_functional_ThrowingFunction {
   _gql_meta: org_apache_causeway_commons_functional_ThrowingFunction__meta
+  _gql_mutations: 
org_apache_causeway_commons_functional_ThrowingFunction__mutations
 }
 
 type org_apache_causeway_commons_functional_ThrowingFunction__meta {
@@ -488,6 +495,7 @@ type 
org_apache_causeway_commons_functional_ThrowingFunction__mutations {
 
 type org_apache_causeway_commons_functional_ThrowingRunnable {
   _gql_meta: org_apache_causeway_commons_functional_ThrowingRunnable__meta
+  _gql_mutations: 
org_apache_causeway_commons_functional_ThrowingRunnable__mutations
 }
 
 type org_apache_causeway_commons_functional_ThrowingRunnable__meta {
@@ -505,6 +513,7 @@ type 
org_apache_causeway_commons_functional_ThrowingRunnable__mutations {
 
 type org_apache_causeway_commons_functional_Try {
   _gql_meta: org_apache_causeway_commons_functional_Try__meta
+  _gql_mutations: org_apache_causeway_commons_functional_Try__mutations
   failure: String!
   success: String!
 }
@@ -548,6 +557,7 @@ type 
org_apache_causeway_core_metamodel_inspect_model_MMNode__meta {
 
 type org_apache_causeway_core_metamodel_inspect_model_MemberNode {
   _gql_meta: org_apache_causeway_core_metamodel_inspect_model_MemberNode__meta
+  _gql_mutations: 
org_apache_causeway_core_metamodel_inspect_model_MemberNode__mutations
   mixedIn: String!
   parentNode: causeway_applib_TypeNode!
 }
@@ -591,6 +601,7 @@ type university_dept_Department__meta {
 
 type university_dept_DeptHead {
   _gql_meta: university_dept_DeptHead__meta
+  _gql_mutations: university_dept_DeptHead__mutations
   department: university_dept_Department
   name: String
 }
diff --git 
a/incubator/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
 
b/incubator/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
index 91d8f46a6d..aab35e69af 100644
--- 
a/incubator/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
+++ 
b/incubator/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
@@ -23,6 +23,7 @@ import static 
graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
 import static graphql.schema.GraphQLObjectType.newObject;
 
 import java.util.Comparator;
+import java.util.List;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
@@ -107,10 +108,12 @@ public class GraphQlSourceForCauseway implements 
GraphQlSource {
         // (and also add behaviour to the child types)
         val topLevelQuery = new GqlvTopLevelQuery(serviceRegistry, 
codeRegistryBuilder);
 
-        specificationLoader.snapshotSpecifications()
-            .distinct((a, b) -> 
a.getLogicalTypeName().equals(b.getLogicalTypeName()))
-            .sorted(Comparator.comparing(HasLogicalType::getLogicalTypeName))
-            .forEach(objectSpec -> addToSchema(objectSpec, topLevelQuery, 
codeRegistryBuilder));
+        List<ObjectSpecification> objectSpecifications = 
specificationLoader.snapshotSpecifications()
+                .distinct((a, b) -> 
a.getLogicalTypeName().equals(b.getLogicalTypeName()))
+                .filter(x -> x.isEntityOrViewModelOrAbstract() || 
x.getBeanSort().isManagedBeanContributing())
+                
.sorted(Comparator.comparing(HasLogicalType::getLogicalTypeName))
+                .toList();
+        objectSpecifications.forEach(objectSpec -> addToSchema(objectSpec, 
topLevelQuery, codeRegistryBuilder));
 
         topLevelQuery.buildQueryType();
 

Reply via email to