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 29144d76e107fa732322d3070ee13dafe96b264d
Author: danhaywood <[email protected]>
AuthorDate: Tue Feb 13 16:46:54 2024 +0000

    CAUSEWAY-3676: includes mutations in non-spec compliant
---
 .../apache/causeway/core/config/CausewayConfiguration.java    | 10 +++++-----
 .../graphql/viewer/integration/GraphQlSourceForCauseway.java  | 11 +++--------
 2 files changed, 8 insertions(+), 13 deletions(-)

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 760fe7baed..f5583682e6 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
@@ -2360,14 +2360,14 @@ public class CausewayConfiguration {
                  */
                 QUERY_AND_MUTATIONS,
                 /**
-                 * Exposes only a Query API, but relaxes the rule that system 
state may not be changed by also including
-                 * idempotent and non-idempotent actions as part of the 
schema.  Modifiable properties
-                 * can also be set.
+                 * Exposes an API with both Query and Mutations, but relaxes 
the constraints for the Query API by also
+                 * including idempotent and non-idempotent actions and 
property setters.
                  *
                  * <p>
                  *     <b>IMPORTANT</b>: be aware that the resultant API is 
not compliant with the rules of the
-                 *     GraphQL spec; in particular, it violates <a 
href="https://spec.graphql.org/June2018/#sec-Language.Operations";>2.3 
Operations</a> which states:
-                 *     &quot;query – [is] a read‐only fetch.&quot;
+                 *     GraphQL spec; in particular, it violates
+                 *     <a 
href="https://spec.graphql.org/June2018/#sec-Language.Operations";>2.3 
Operations</a> which
+                 *     states: &quot;query – [is] a read‐only fetch.&quot;
                  * </p>
                  */
                 QUERY_WITH_MUTATIONS_NON_SPEC_COMPLIANT,
diff --git 
a/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
 
b/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
index 2e2b057f8f..b1475ddb38 100644
--- 
a/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
+++ 
b/viewers/graphql/viewer/src/main/java/org/apache/causeway/viewer/graphql/viewer/integration/GraphQlSourceForCauseway.java
@@ -90,16 +90,11 @@ public class GraphQlSourceForCauseway implements 
GraphQlSource {
 
         // top-level query and mutation type
         val topLevelQuery = new GqlvTopLevelQuery(context);
-        val topLevelMutation =
-                causewayConfiguration.getViewer().getGraphql().getApiVariant() 
== CausewayConfiguration.Viewer.Graphql.ApiVariant.QUERY_AND_MUTATIONS ?
-                        new GqlvTopLevelMutation(context)
-                        : null;
+        val topLevelMutation = new GqlvTopLevelMutation(context);
 
         // add the data fetchers
         topLevelQuery.addDataFetchers();
-        if (topLevelMutation != null) {
-            topLevelMutation.addDataFetchers();
-        }
+        topLevelMutation.addDataFetchers();
 
         // finalize the fetcher/mutator code that's been added
         val codeRegistry = context.codeRegistryBuilder.build();
@@ -107,9 +102,9 @@ public class GraphQlSourceForCauseway implements 
GraphQlSource {
         // build the schema
         return GraphQLSchema.newSchema()
                 .query(topLevelQuery.getGqlObjectType())
+                .mutation(topLevelMutation.getGqlObjectType())
                 .additionalTypes(graphQLTypeRegistry.getGraphQLTypes())
                 .codeRegistry(codeRegistry)
-                .mutation(topLevelMutation != null ? 
topLevelMutation.getGqlObjectType() : null)
                 .build();
     }
 

Reply via email to