Search in sources :

Example 11 with GraphQLNamedOutputType

use of graphql.schema.GraphQLNamedOutputType in project graphql-java by graphql-java.

the class SchemaUtil method groupInterfaceImplementationsByName.

public static ImmutableMap<String, List<GraphQLObjectType>> groupInterfaceImplementationsByName(List<GraphQLNamedType> allTypesAsList) {
    Map<String, List<GraphQLObjectType>> result = new LinkedHashMap<>();
    for (GraphQLType type : allTypesAsList) {
        if (type instanceof GraphQLObjectType) {
            List<GraphQLNamedOutputType> interfaces = ((GraphQLObjectType) type).getInterfaces();
            for (GraphQLNamedOutputType interfaceType : interfaces) {
                List<GraphQLObjectType> myGroup = result.computeIfAbsent(interfaceType.getName(), k -> new ArrayList<>());
                myGroup.add((GraphQLObjectType) type);
            }
        }
    }
    return ImmutableMap.copyOf(new TreeMap<>(result));
}
Also used : GraphQLType(graphql.schema.GraphQLType) GraphQLObjectType(graphql.schema.GraphQLObjectType) ArrayList(java.util.ArrayList) List(java.util.List) GraphQLNamedOutputType(graphql.schema.GraphQLNamedOutputType) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

GraphQLNamedOutputType (graphql.schema.GraphQLNamedOutputType)11 GraphQLObjectType (graphql.schema.GraphQLObjectType)8 GraphQLType (graphql.schema.GraphQLType)7 List (java.util.List)7 GraphQLInterfaceType (graphql.schema.GraphQLInterfaceType)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 GraphQLArgument (graphql.schema.GraphQLArgument)5 GraphQLDirective (graphql.schema.GraphQLDirective)5 GraphQLFieldDefinition (graphql.schema.GraphQLFieldDefinition)5 GraphQLInputObjectField (graphql.schema.GraphQLInputObjectField)5 GraphQLSchema (graphql.schema.GraphQLSchema)5 LinkedHashMap (java.util.LinkedHashMap)5 Assert.assertNotNull (graphql.Assert.assertNotNull)4 GraphQLUnionType (graphql.schema.GraphQLUnionType)4 AssertException (graphql.AssertException)3 DEPRECATED_DIRECTIVE_DEFINITION (graphql.Directives.DEPRECATED_DIRECTIVE_DEFINITION)3 SPECIFIED_BY_DIRECTIVE_DEFINITION (graphql.Directives.SPECIFIED_BY_DIRECTIVE_DEFINITION)3 SpecifiedByDirective (graphql.Directives.SpecifiedByDirective)3 Internal (graphql.Internal)3