Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a problem where during the scanning of InputTypes it included synthetic methods, added a filter + test #1966

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void addFields(InputType inputType, ClassInfo classInfo, Reference refer
// Find all methods and properties up the tree
for (ClassInfo c = classInfo; c != null; c = ScanningContext.getIndex().getClassByName(c.superName())) {
if (!c.toString().startsWith(JAVA_DOT)) { // Not java objects
allMethods.addAll(c.methods());
c.methods().stream().filter(methodInfo -> !methodInfo.isSynthetic()).forEach(allMethods::add);
for (final FieldInfo fieldInfo : c.fields()) {
allFields.putIfAbsent(fieldInfo.name(), fieldInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ public void testGenericSchemaBuilding() {
Set<Operation> mutations = schema.getMutations();
Map<String, Type> outputTypes = schema.getTypes();

assertEquals(queries.size(), 2);
assertEquals(mutations.size(), 4);
assertEquals(queries.size(), 3);
assertEquals(mutations.size(), 5);

Operation firstQuery = queries.stream()
.filter(q -> q.getName().equals("heroes"))
Expand All @@ -221,6 +221,12 @@ public void testGenericSchemaBuilding() {
Type greetingType = outputTypes.get("Greet");
assertNotNull(greetingType);

Operation thirdQuery = queries.stream()
.filter(q -> q.getName().equals("saySome")).findFirst().orElseThrow(AssertionError::new);
assertEquals(thirdQuery.getArguments().size(), 1);
assertEquals(thirdQuery.getArguments().get(0).getReference().getName(), "SomeInput");
assertEquals(thirdQuery.getReference().getName(), "Some");

// ------------------------------------------------------------------
// MUTATIONS
Operation firstMutation = mutations.stream()
Expand Down Expand Up @@ -281,6 +287,17 @@ public void testGenericSchemaBuilding() {
// return type
assertEquals(fourthMutation.getReference().getName(), "Hero");

Operation fifthMutation = mutations.stream()
.filter(q -> q.getName().equals("updateSome"))
.findFirst()
.orElseThrow(AssertionError::new);

// arguments
assertEquals(fifthMutation.getArguments().size(), 1);
assertEquals(fifthMutation.getArguments().get(0).getReference().getName(), "SomeInput");
// return type
assertEquals(fifthMutation.getReference().getName(), "Some");

}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.smallrye.graphql.index.generic;

public interface Attribute<T> {
T getValue();

void setValue(T value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ public ResponseComposite sayHello(String name) {
return null;
}

@Query
public Some saySome(Some value) {
return null;
}

@Mutation
public Some updateSome(Some some) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.smallrye.graphql.index.generic;

public class Some implements Attribute<Long> {
Long some;

public Some() {
}

public Some(Long some) {
this.some = some;
}

@Override
public Long getValue() {
return some;
}

@Override
public void setValue(Long value) {
this.some = value;
}
}
Loading