11/**
22 * Copyright 2016 Yurii Rashkovskii
3- *
3+ * <p>
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
7+ * <p>
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ * <p>
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515package graphql .annotations ;
1616
1717import graphql .TypeResolutionEnvironment ;
18- import graphql .annotations .connection .ConnectionDataFetcher ;
19- import graphql .annotations .connection .ConnectionTypeValidator ;
20- import graphql .annotations .connection .GraphQLConnection ;
18+ import graphql .annotations .connection .*;
2119import graphql .relay .Relay ;
2220import graphql .schema .*;
2321import graphql .schema .GraphQLNonNull ;
@@ -603,7 +601,6 @@ private GraphQLObjectType getActualType(GraphQLObjectType type) {
603601 }
604602
605603 private boolean isConnection (AccessibleObject obj , GraphQLOutputType type ) {
606- ConnectionTypeValidator validator = new ConnectionTypeValidator ();
607604 if (type instanceof GraphQLNonNull ) {
608605 type = (GraphQLOutputType ) ((GraphQLNonNull ) type ).getWrappedType ();
609606 }
@@ -613,7 +610,8 @@ private boolean isConnection(AccessibleObject obj, GraphQLOutputType type) {
613610 actualType instanceof GraphQLList && TYPES_FOR_CONNECTION .stream ().anyMatch (aClass ->
614611 aClass .isInstance (((GraphQLList ) actualType ).getWrappedType ()));
615612
616- if (isValidGraphQLTypeForConnection ) {
613+ if (isValidGraphQLTypeForConnection ) {
614+ ConnectionValidator validator = newInstance (obj .getAnnotation (GraphQLConnection .class ).validator ());
617615 validator .validate (obj );
618616 return true ;
619617 } else {
0 commit comments