@@ -471,18 +471,8 @@ private GraphQLFieldDefinition getObjectField(Attribute attribute) {
471471 Stream <Attribute > attributes = findBasicAttributes (foreignType .getAttributes ());
472472
473473 // TODO fix page count query
474- // TODO fix argument bindings. Only static parameter bindings are supported due to GraphQL limitation
475474 arguments .add (getWhereArgument (foreignType ));
476475
477- // Disabled Simple attribute filtering
478- // attributes.forEach(it -> {
479- // arguments.add(GraphQLArgument.newArgument()
480- // .name(it.getName())
481- // .type((GraphQLInputType) getAttributeType(it))
482- // .build()
483- // );
484- // });
485-
486476 } // Get Sub-Objects fields queries via DataFetcher
487477 else if (attribute instanceof PluralAttribute
488478 && (attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ONE_TO_MANY
@@ -513,22 +503,24 @@ private Stream<Attribute<?,?>> findBasicAttributes(Collection<Attribute<?,?>> at
513503
514504 @ SuppressWarnings ( "rawtypes" )
515505 private GraphQLType getAttributeType (Attribute <?,?> attribute ) {
516- if (attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .BASIC ) {
517- if (attribute .getJavaType ().isEnum ()) {
518- return getTypeFromJavaType (attribute .getJavaType ());
519- } else {
520- return JavaScalars .of (attribute .getJavaType ());
521- }
522-
523- } else if (attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ONE_TO_MANY || attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .MANY_TO_MANY ) {
506+
507+ if (isBasic (attribute )) {
508+ return getGraphQLTypeFromJavaType (attribute .getJavaType ());
509+ }
510+ else if (isToMany (attribute )) {
524511 EntityType foreignType = (EntityType ) ((PluralAttribute ) attribute ).getElementType ();
525512 return new GraphQLList (new GraphQLTypeReference (foreignType .getName ()));
526- } else if (attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .MANY_TO_ONE || attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ONE_TO_ONE ) {
513+ }
514+ else if (isToOne (attribute )) {
527515 EntityType foreignType = (EntityType ) ((SingularAttribute ) attribute ).getType ();
528516 return new GraphQLTypeReference (foreignType .getName ());
529- } else if (attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ELEMENT_COLLECTION ) {
517+ }
518+ else if (isElementCollection (attribute )) {
530519 Type foreignType = ((PluralAttribute ) attribute ).getElementType ();
531- return new GraphQLList (getTypeFromJavaType (foreignType .getJavaType ()));
520+
521+ if (foreignType .getPersistenceType () == Type .PersistenceType .BASIC ) {
522+ return new GraphQLList (getGraphQLTypeFromJavaType (foreignType .getJavaType ()));
523+ }
532524 }
533525
534526 final String declaringType = attribute .getDeclaringType ().getJavaType ().getName (); // fully qualified name of the entity class
@@ -538,7 +530,26 @@ private GraphQLType getAttributeType(Attribute<?,?> attribute) {
538530 "Attribute could not be mapped to GraphQL: field '" + declaringMember + "' of entity class '" + declaringType +"'" );
539531 }
540532
541- private boolean isValidInput (Attribute <?,?> attribute ) {
533+ protected final boolean isBasic (Attribute <?,?> attribute ) {
534+ return attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .BASIC ;
535+ }
536+
537+ protected final boolean isElementCollection (Attribute <?,?> attribute ) {
538+ return attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ELEMENT_COLLECTION ;
539+ }
540+
541+ protected final boolean isToMany (Attribute <?,?> attribute ) {
542+ return attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ONE_TO_MANY
543+ || attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .MANY_TO_MANY ;
544+ }
545+
546+ protected final boolean isToOne (Attribute <?,?> attribute ) {
547+ return attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .MANY_TO_ONE
548+ || attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ONE_TO_ONE ;
549+ }
550+
551+
552+ protected final boolean isValidInput (Attribute <?,?> attribute ) {
542553 return attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .BASIC ||
543554 attribute .getPersistentAttributeType () == Attribute .PersistentAttributeType .ELEMENT_COLLECTION ;
544555 }
@@ -586,7 +597,7 @@ private boolean isNotIgnored(AnnotatedElement annotatedElement) {
586597 }
587598
588599 @ SuppressWarnings ( "unchecked" )
589- private GraphQLType getTypeFromJavaType (Class <?> clazz ) {
600+ private GraphQLType getGraphQLTypeFromJavaType (Class <?> clazz ) {
590601 if (clazz .isEnum ()) {
591602
592603 if (classCache .containsKey (clazz ))
@@ -597,15 +608,15 @@ private GraphQLType getTypeFromJavaType(Class<?> clazz) {
597608 for (Enum <?> enumValue : ((Class <Enum <?>>)clazz ).getEnumConstants ())
598609 enumBuilder .value (enumValue .name (), ordinal ++);
599610
600- GraphQLType answer = enumBuilder .build ();
601- setNoOpCoercing (answer );
611+ GraphQLType enumType = enumBuilder .build ();
612+ setNoOpCoercing (enumType );
602613
603- classCache .putIfAbsent (clazz , answer );
614+ classCache .putIfAbsent (clazz , enumType );
604615
605- return answer ;
616+ return enumType ;
606617 }
607618
608- return null ;
619+ return JavaScalars . of ( clazz ) ;
609620 }
610621
611622 protected GraphQLInputType getFieldsEnumType (EntityType <?> entityType ) {
0 commit comments