-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Query generator #3979
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
Query generator #3979
Conversation
|
||
import java.util.function.Predicate; | ||
|
||
public class QueryGeneratorOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Expimental
this.filterFieldDefinitionPredicate = filterFieldDefinitionPredicate; | ||
} | ||
|
||
public int getMaxFieldCount() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java doc
return maxFieldCount; | ||
} | ||
|
||
public Predicate<GraphQLFieldsContainer> getFilterFieldContainerPredicate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java doc
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.stream.Collectors; | ||
|
||
public class QueryGeneratorFieldSelection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ExperimentlApi
public String generateQuery( | ||
String operationFieldPath, | ||
@Nullable String operationName, | ||
@Nullable String arguments, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc
I am unsure what arguments
and typeClassifier
mean
@@ -0,0 +1,82 @@ | |||
package graphql.util.querygenerator; | |||
|
|||
import com.google.common.base.Predicates; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a checker in the build to look for new Guava imports, and we prefer to not add new imports.
Is it possible to use the plain Java version of this instead?
Thanks @bbakerman and @dondonz I addressed your comments. |
import graphql.schema.GraphQLSchema; | ||
import graphql.schema.GraphQLUnionType; | ||
|
||
import javax.annotation.Nullable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small one: could you change this to be the JSpecify Nullable annotation, rather than javax?
I'll amend the ArchUnit test so this gets automatically picked up in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ;-)
Out of curiosity: what's the advantage of the JSpecify version of Nullable when compared to the native one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep good question, it is only an annotation at the end of the day so there isn't inherently something "new" about JSpecify's "implementation", but the advantage is that it has become a standard because all the big industry players are behind it. For example, Spring have formally adopted it, even at work JSpecify (& NullAway) will soon become a standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
A little utility function that allows people to generate queries for a certain type.
This will be useful for a use case I'm working on at the moment, where I need to generate test queries that contain as many fields as possible.
The
generated-query-for-extra-large-schema-1.graphql
file contains an example of a generated query for a somewhat complex type.Let me know what y'all think!