3
3
import static com .intuit .graphql .orchestrator .resolverdirective .FieldResolverDirectiveUtil .canContainFieldResolverDirective ;
4
4
import static com .intuit .graphql .orchestrator .resolverdirective .FieldResolverDirectiveUtil .createFieldResolverContexts ;
5
5
6
- import com .intuit .graphql .graphQL .Directive ;
7
6
import com .intuit .graphql .graphQL .FieldDefinition ;
8
7
import com .intuit .graphql .orchestrator .resolverdirective .ArgumentDefinitionNotAllowed ;
9
8
import com .intuit .graphql .orchestrator .resolverdirective .FieldResolverDirectiveUtil ;
10
- import com .intuit .graphql .orchestrator .resolverdirective .InvalidDirectivePairingException ;
11
9
import com .intuit .graphql .orchestrator .resolverdirective .NotAValidLocationForFieldResolverDirective ;
12
10
import com .intuit .graphql .orchestrator .utils .XtextTypeUtils ;
13
- import com .intuit .graphql .orchestrator .utils .XtextUtils ;
14
11
import com .intuit .graphql .orchestrator .xtext .XtextGraph ;
15
12
import java .util .ArrayList ;
16
13
import java .util .List ;
17
14
import java .util .Objects ;
18
15
import org .apache .commons .collections4 .CollectionUtils ;
19
- import org .eclipse .emf .common .util .EList ;
20
16
import org .eclipse .emf .ecore .EObject ;
21
17
22
18
public class FieldResolverTransformerPreMerge implements Transformer <XtextGraph , XtextGraph > {
@@ -43,37 +39,21 @@ public XtextGraph transform(XtextGraph sourceXtextGraph) {
43
39
}
44
40
45
41
private void validateFieldWithResolver (List <FieldResolverContext > fieldResolverContexts ) {
46
- fieldResolverContexts
47
- .forEach (fieldResolverContext -> {
48
- FieldDefinition fieldDefinition = fieldResolverContext .getFieldDefinition ();
49
- String fieldName = fieldDefinition .getName ();
50
- String parentTypeName = XtextTypeUtils .getParentTypeName (fieldDefinition );
51
-
52
- EObject parentType = fieldDefinition .eContainer ();
53
- if (!(canContainFieldResolverDirective (parentType ))) {
54
- throw new NotAValidLocationForFieldResolverDirective (fieldName , parentTypeName );
55
- }
56
-
57
- if (hasArguments (fieldDefinition )) {
58
- throw new ArgumentDefinitionNotAllowed (fieldName , parentTypeName );
59
- }
60
-
61
- EList <Directive > directives = fieldDefinition .getDirectives ();
62
-
63
- boolean [] properDirectivesDefs = {false };
64
-
65
- XtextUtils .getDirectivesWithNameFromDefinition ((FieldDefinition ) directives , "external" )
66
- .forEach (directive -> properDirectivesDefs [0 ] = true );
67
- XtextUtils .getDirectivesWithNameFromDefinition ((FieldDefinition ) directives , "provides" )
68
- .forEach (directive -> properDirectivesDefs [0 ] = true );
69
- XtextUtils .getDirectivesWithNameFromDefinition ((FieldDefinition ) directives , "requires" )
70
- .forEach (directive -> properDirectivesDefs [0 ] = true );
71
-
72
- if (properDirectivesDefs [0 ]) {
73
- throw new InvalidDirectivePairingException (fieldName , parentTypeName );
74
- }
75
-
76
- });
42
+ fieldResolverContexts
43
+ .forEach (fieldResolverContext -> {
44
+ FieldDefinition fieldDefinition = fieldResolverContext .getFieldDefinition ();
45
+ String fieldName = fieldDefinition .getName ();
46
+ String parentTypeName = XtextTypeUtils .getParentTypeName (fieldDefinition );
47
+
48
+ EObject parentType = fieldDefinition .eContainer ();
49
+ if (!(canContainFieldResolverDirective (parentType ))) {
50
+ throw new NotAValidLocationForFieldResolverDirective (fieldName , parentTypeName );
51
+ }
52
+
53
+ if (hasArguments (fieldDefinition )) {
54
+ throw new ArgumentDefinitionNotAllowed (fieldName , parentTypeName );
55
+ }
56
+ });
77
57
}
78
58
79
59
private boolean hasArguments (FieldDefinition fieldDefinition ) {
0 commit comments