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 10d943012472641d4e8cc003c2632e7c97286b5b Author: danhaywood <[email protected]> AuthorDate: Sat Jan 20 16:50:20 2024 +0000 CAUSEWAY-3676: refactor registering object's types --- .../causeway/viewer/graphql/model/domain/GqlvDomainObject.java | 7 +++++-- .../graphql/viewer/integration/GraphQlSourceForCauseway.java | 8 ++------ 2 files changed, 7 insertions(+), 8 deletions(-) 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 ee447335e5..2cad9f1198 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 @@ -276,7 +276,7 @@ public class GqlvDomainObject { * * @see #getGqlObjectType() */ - public GraphQLObjectType buildGqlObjectType() { + private GraphQLObjectType buildGqlObjectType() { if (gqlObjectType != null) { throw new IllegalArgumentException(String.format("GqlObjectType has already been built for %s", getLogicalTypeName())); } @@ -418,7 +418,10 @@ public class GqlvDomainObject { return mutatorsType; } - public void addTypesInto(GraphQLTypeRegistry graphQLTypeRegistry) { + public void registerTypesInto(GraphQLTypeRegistry graphQLTypeRegistry) { + + GraphQLObjectType graphQLObjectType = buildGqlObjectType(); + graphQLTypeRegistry.addTypeIfNotAlreadyPresent(graphQLObjectType); graphQLTypeRegistry.addTypeIfNotAlreadyPresent(getMeta().getMetaField().getType()); graphQLTypeRegistry.addTypeIfNotAlreadyPresent(getGqlInputObjectType()); 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 353e911cc5..5693f6a8fa 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 @@ -53,7 +53,6 @@ import org.apache.causeway.core.metamodel.specloader.SpecificationLoader; import graphql.GraphQL; import graphql.schema.GraphQLCodeRegistry; -import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLSchema; import lombok.RequiredArgsConstructor; @@ -203,11 +202,8 @@ public class GraphQlSourceForCauseway implements GraphQlSource { gqlvDomainObject.addCollectionsAsLists(); gqlvDomainObject.addActionsAsFields(); - // build and register object type - GraphQLObjectType graphQLObjectType = gqlvDomainObject.buildGqlObjectType(); - graphQLTypeRegistry.addTypeIfNotAlreadyPresent(graphQLObjectType); - - gqlvDomainObject.addTypesInto(graphQLTypeRegistry); + // build + gqlvDomainObject.registerTypesInto(graphQLTypeRegistry); // create and register data fetchers gqlvDomainObject.addDataFetchersForMetaData();
