graphql.schema.GraphqlTypeComparatorRegistry Java Examples

The following examples show how to use graphql.schema.GraphqlTypeComparatorRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FederationSdlPrinter.java    From federation-jvm with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: DefaultTypeInfoGenerator.java    From graphql-spqr with Apache License 2.0 6 votes vote down vote up
@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);
        }
    };
}
 
Example #3
Source File: DefaultTypeInfoGenerator.java    From graphql-spqr with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #4
Source File: FederationSdlPrinter.java    From federation-jvm with MIT License 4 votes vote down vote up
public GraphqlTypeComparatorRegistry getComparatorRegistry() {
    return comparatorRegistry;
}
 
Example #5
Source File: BuildContext.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
public GraphqlTypeComparatorRegistry comparatorRegistry(AnnotatedType type) {
    return typeInfoGenerator.generateComparatorRegistry(type, messageBundle);
}
 
Example #6
Source File: FederationSdlPrinter.java    From federation-jvm with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: TypeInfoGenerator.java    From graphql-spqr with Apache License 2.0 votes vote down vote up
GraphqlTypeComparatorRegistry generateComparatorRegistry(AnnotatedType type, MessageBundle messageBundle);