@@ -162,6 +162,7 @@ public class GraphQLJpaSchemaBuilder implements GraphQLSchemaBuilder {
162
162
private final Relay relay = new Relay ();
163
163
164
164
private final List <String > entityPaths = new ArrayList <>();
165
+ private final List <String > additionalTypes = new ArrayList <>();
165
166
166
167
private final Supplier <BatchLoaderRegistry > batchLoadersRegistry = BatchLoaderRegistry ::getInstance ;
167
168
private final Function <String , EntityType <?>> entityObjectTypeResolver = entityTypeMap ::get ;
@@ -190,6 +191,7 @@ public GraphQLSchema build() {
190
191
.getEntities ()
191
192
.stream ()
192
193
.filter (Predicate .not (entityCache ::containsKey ))
194
+ .filter (this ::isAdditionalType )
193
195
.forEach (entity -> schema .additionalType (getEntityObjectType (entity )));
194
196
195
197
if (enableSubscription ) {
@@ -1715,6 +1717,12 @@ protected boolean isNotIgnoredOrder(Attribute<?, ?> attribute) {
1715
1717
return false ;
1716
1718
}
1717
1719
1720
+ private boolean isAdditionalType (EntityType <?> entityType ) {
1721
+ return additionalTypes
1722
+ .stream ()
1723
+ .anyMatch (additionalType -> entityType .getJavaType ().getName ().startsWith (additionalType ));
1724
+ }
1725
+
1718
1726
@ SuppressWarnings ("unchecked" )
1719
1727
private GraphQLOutputType getGraphQLTypeFromJavaType (Class <?> clazz ) {
1720
1728
if (clazz .isEnum ()) {
@@ -1887,6 +1895,15 @@ public GraphQLJpaSchemaBuilder entityPath(String path) {
1887
1895
return this ;
1888
1896
}
1889
1897
1898
+ @ Override
1899
+ public GraphQLJpaSchemaBuilder additionalType (String type ) {
1900
+ Assert .assertNotNull (type , () -> "type can't be null" );
1901
+
1902
+ additionalTypes .add (type );
1903
+
1904
+ return this ;
1905
+ }
1906
+
1890
1907
public GraphQLJpaSchemaBuilder queryByIdFieldNameCustomizer (Function <String , String > queryByIdFieldNameCustomizer ) {
1891
1908
this .queryByIdFieldNameCustomizer = queryByIdFieldNameCustomizer ;
1892
1909
0 commit comments