Skip to content

Commit 3e53e65

Browse files
committed
fixed a bug that could cause directives to be built with synthetic fields
1 parent cfdba31 commit 3e53e65

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/main/java/graphql/annotations/processor/directives/DirectiveArgumentCreator.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public DirectiveArgumentCreator(CommonPropertiesCreator commonPropertiesCreator,
3535
this.container = container;
3636
}
3737

38-
3938
public GraphQLArgument getArgument(Field field, Class<?> containingClass) {
4039
GraphQLArgument.Builder builder = newArgument()
4140
.name(commonPropertiesCreator.getName(field))
@@ -60,6 +59,4 @@ private GraphQLInputType getType(Field field) {
6059
return (GraphQLInputType) typeFunction.buildType(true, field.getType(),
6160
field.getAnnotatedType(), container);
6261
}
63-
64-
6562
}

src/main/java/graphql/annotations/processor/directives/DirectiveCreator.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public DirectiveCreator(DirectiveArgumentCreator directiveArgumentCreator, Commo
3636

3737
public GraphQLDirective getDirective(Class<?> annotatedClass) {
3838
GraphQLDirective.Builder builder = newDirective()
39-
.name(commonPropertiesCreator.getName(annotatedClass))
40-
.description(commonPropertiesCreator.getDescription(annotatedClass));
39+
.name(commonPropertiesCreator.getName(annotatedClass))
40+
.description(commonPropertiesCreator.getDescription(annotatedClass));
4141
Introspection.DirectiveLocation[] validLocations = getValidLocations(annotatedClass);
4242
if (validLocations == null || validLocations.length == 0) {
4343
throw new GraphQLAnnotationsException("No valid locations defined on directive", null);
@@ -49,17 +49,18 @@ public GraphQLDirective getDirective(Class<?> annotatedClass) {
4949
}
5050

5151
private void buildArguments(GraphQLDirective.Builder builder, Class<?> annotatedClass) {
52-
Arrays.stream(annotatedClass.getDeclaredFields()).forEach(x ->
53-
builder.argument(directiveArgumentCreator.getArgument(x, annotatedClass)));
52+
Arrays.stream(annotatedClass.getDeclaredFields()).forEach(x -> {
53+
if (!x.isSynthetic()) {
54+
builder.argument(directiveArgumentCreator.getArgument(x, annotatedClass));
55+
}
56+
});
5457
}
5558

56-
5759
private Introspection.DirectiveLocation[] getValidLocations(Class<?> annotatedClass) {
5860
DirectiveLocations directiveLocationsAnnotation = annotatedClass.getAnnotation(DirectiveLocations.class);
5961
if (directiveLocationsAnnotation != null) {
6062
return directiveLocationsAnnotation.value();
6163
}
6264
return null;
6365
}
64-
6566
}

0 commit comments

Comments
 (0)