Java源码示例:graphql.schema.GraphqlTypeComparatorRegistry
示例1
private Options(boolean includeIntrospectionTypes,
boolean includeScalars,
boolean includeExtendedScalars,
boolean includeSchemaDefinition,
boolean useAstDefinitions,
boolean descriptionsAsHashComments,
Predicate<GraphQLDirective> includeDirective,
Predicate<GraphQLDirective> includeDirectiveDefinition,
Predicate<GraphQLNamedType> includeTypeDefinition,
GraphqlTypeComparatorRegistry comparatorRegistry) {
this.includeIntrospectionTypes = includeIntrospectionTypes;
this.includeScalars = includeScalars;
this.includeExtendedScalars = includeExtendedScalars;
this.includeSchemaDefinition = includeSchemaDefinition;
this.includeDirective = includeDirective;
this.includeDirectiveDefinition = includeDirectiveDefinition;
this.includeTypeDefinition = includeTypeDefinition;
this.useAstDefinitions = useAstDefinitions;
this.descriptionsAsHashComments = descriptionsAsHashComments;
this.comparatorRegistry = comparatorRegistry;
}
示例2
@Override
public GraphqlTypeComparatorRegistry generateComparatorRegistry(AnnotatedType type, MessageBundle messageBundle) {
if (!isOrdered(type)) {
return DEFAULT_REGISTRY;
}
return new GraphqlTypeComparatorRegistry() {
@Override
public <T extends GraphQLSchemaElement> Comparator<? super T> getComparator(GraphqlTypeComparatorEnvironment env) {
if (env.getElementType().equals(GraphQLFieldDefinition.class)) {
return comparator(getFieldOrder(type, messageBundle), env);
}
if (env.getElementType().equals(GraphQLInputObjectField.class)
|| env.getElementType().equals(GraphQLEnumValueDefinition.class)) {
return comparator(getInputFieldOrder(type, messageBundle), env);
}
return DEFAULT_REGISTRY.getComparator(env);
}
};
}
示例3
@Override
public <T extends GraphQLSchemaElement> Comparator<? super T> getComparator(GraphqlTypeComparatorEnvironment env) {
//Leave the arguments in the declared order
if (env.getElementType().equals(GraphQLArgument.class)) {
return GraphqlTypeComparatorRegistry.AS_IS_REGISTRY.getComparator(env);
}
//Sort everything else by name
return GraphqlTypeComparatorRegistry.BY_NAME_REGISTRY.getComparator(env);
}
示例4
public GraphqlTypeComparatorRegistry getComparatorRegistry() {
return comparatorRegistry;
}
示例5
public GraphqlTypeComparatorRegistry comparatorRegistry(AnnotatedType type) {
return typeInfoGenerator.generateComparatorRegistry(type, messageBundle);
}
示例6
/**
* The comparator registry controls the printing order for registered {@code GraphQLType}s.
* <p>
* The default is to sort elements by name but you can put in your own code to decide on the field order
*
* @param comparatorRegistry The registry containing the {@code Comparator} and environment scoping rules.
* @return options
*/
public Options setComparators(GraphqlTypeComparatorRegistry comparatorRegistry) {
return new Options(this.includeIntrospectionTypes, this.includeScalars, this.includeExtendedScalars, this.includeSchemaDefinition, this.useAstDefinitions, this.descriptionsAsHashComments, this.includeDirective, this.includeDirectiveDefinition, this.includeTypeDefinition, comparatorRegistry);
}
示例7
GraphqlTypeComparatorRegistry generateComparatorRegistry(AnnotatedType type, MessageBundle messageBundle);