boolean objectImplementsInterface(GraphQLInterfaceType interfaceType, GraphQLObjectType objectType) { return objectType.getInterfaces().contains(interfaceType); }
private void check(GraphQLObjectType objectType, SchemaValidationErrorCollector validationErrorCollector) { List<GraphQLOutputType> interfaces = objectType.getInterfaces(); interfaces.forEach(interfaceType -> { // we have resolved the interfaces at this point and hence the cast is ok checkObjectImplementsInterface(objectType, (GraphQLInterfaceType) interfaceType, validationErrorCollector); }); }
Map<String, List<GraphQLObjectType>> groupImplementations(GraphQLSchema schema) { Map<String, List<GraphQLObjectType>> result = new LinkedHashMap<>(); for (GraphQLType type : schema.getAllTypesAsList()) { if (type instanceof GraphQLObjectType) { for (GraphQLOutputType interfaceType : ((GraphQLObjectType) type).getInterfaces()) { List<GraphQLObjectType> myGroup = result.computeIfAbsent(interfaceType.getName(), k -> new ArrayList<>()); myGroup.add((GraphQLObjectType) type); } } } return result; }
@Override public TraversalControl visitGraphQLObjectType(GraphQLObjectType node, TraverserContext<GraphQLType> context) { node.replaceInterfaces(node.getInterfaces().stream() .map(type -> (GraphQLOutputType) typeMap.get(type.getName())) .collect(Collectors.toList())); return super.visitGraphQLObjectType(node, context); }
if ((objectType).getInterfaces().contains(interfaceType)) { result.add(objectType);
public Builder(GraphQLObjectType existing) { name = existing.getName(); description = existing.getDescription(); definition = existing.getDefinition(); fields.putAll(getByName(existing.getFieldDefinitions(), GraphQLFieldDefinition::getName)); interfaces.putAll(getByName(existing.getInterfaces(), GraphQLType::getName)); directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private TypePrinter<GraphQLObjectType> objectPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); if (type.getInterfaces().isEmpty()) { out.format("type %s%s {\n", type.getName(), directivesString(type.getDirectives())); } else { Stream<String> interfaceNames = type.getInterfaces() .stream() .map(GraphQLType::getName) .sorted(Comparator.naturalOrder()); out.format("type %s implements %s%s {\n", type.getName(), interfaceNames.collect(joining(" & ")), directivesString(type.getDirectives())); } visibility.getFieldDefinitions(type) .stream() .sorted(Comparator.comparing(GraphQLFieldDefinition::getName)) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s%s: %s%s\n", fd.getName(), argsString(fd.getArguments()), typeString(fd.getType()), directivesString(fd.getDirectives())); }); out.format("}\n\n"); }; }
boolean objectImplementsInterface(GraphQLInterfaceType interfaceType, GraphQLObjectType objectType) { return objectType.getInterfaces().contains(interfaceType); }
private void check(GraphQLObjectType objectType, SchemaValidationErrorCollector validationErrorCollector) { List<GraphQLOutputType> interfaces = objectType.getInterfaces(); interfaces.forEach(interfaceType -> { // we have resolved the interfaces at this point and hence the cast is ok checkObjectImplementsInterface(objectType, (GraphQLInterfaceType) interfaceType, validationErrorCollector); }); }
Map<String, List<GraphQLObjectType>> groupImplementations(GraphQLSchema schema) { Map<String, List<GraphQLObjectType>> result = new LinkedHashMap<>(); for (GraphQLType type : schema.getAllTypesAsList()) { if (type instanceof GraphQLObjectType) { for (GraphQLOutputType interfaceType : ((GraphQLObjectType) type).getInterfaces()) { List<GraphQLObjectType> myGroup = result.computeIfAbsent(interfaceType.getName(), k -> new ArrayList<>()); myGroup.add((GraphQLObjectType) type); } } } return result; }
@Override public TraversalControl visitGraphQLObjectType(GraphQLObjectType node, TraverserContext<GraphQLType> context) { node.replaceInterfaces(node.getInterfaces().stream() .map(type -> (GraphQLOutputType) typeMap.get(type.getName())) .collect(Collectors.toList())); return super.visitGraphQLObjectType(node, context); }
if ((objectType).getInterfaces().contains(interfaceType)) { result.add(objectType);
public TypeRegistry(Collection<GraphQLType> knownTypes) { //extract known interface implementations knownTypes.stream() .filter(type -> type instanceof GraphQLObjectType && Directives.isMappedType(type)) .map(type -> (GraphQLObjectType) type) .forEach(obj -> obj.getInterfaces().forEach( inter -> registerCovariantType(inter.getName(), Directives.getMappedType(obj), obj))); //extract known union members knownTypes.stream() .filter(type -> type instanceof GraphQLUnionType) .map(type -> (GraphQLUnionType) type) .forEach(union -> union.getTypes().stream() .filter(type -> type instanceof GraphQLObjectType && Directives.isMappedType(type)) .map(type -> (GraphQLObjectType) type) .forEach(obj -> registerCovariantType(union.getName(), Directives.getMappedType(obj), obj))); }
public GraphQLObjectTypeWrapper(Class<?> objectClass, GraphQLObjectType objectType) { super(objectType.getName(), objectType.getDescription(), objectType.getFieldDefinitions(), objectType.getInterfaces()); this.objectClass = objectClass; }
@Test public void testInterfaces() { GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class); List<GraphQLOutputType> ifaces = object.getInterfaces(); assertEquals(ifaces.size(), 1); assertEquals(ifaces.get(0).getName(), "TestIface"); }
public Builder(GraphQLObjectType existing) { name = existing.getName(); description = existing.getDescription(); definition = existing.getDefinition(); fields.putAll(getByName(existing.getFieldDefinitions(), GraphQLFieldDefinition::getName)); interfaces.putAll(getByName(existing.getInterfaces(), GraphQLType::getName)); directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
unwrappedQueryType = buildContext.typeCache.resolveType(unwrappedQueryType.getName()); if (unwrappedQueryType instanceof GraphQLObjectType && ((GraphQLObjectType) unwrappedQueryType).getInterfaces().contains(node)) { nodeQueriesByType.put(unwrappedQueryType.getName(), query.getName()); } else if (unwrappedQueryType instanceof GraphQLInterfaceType) { typeRegistry.getOutputTypes(unwrappedQueryType.getName()).stream() .map(MappedType::getAsObjectType) .filter(implementation -> implementation.getInterfaces().contains(node)) .filter(implementation -> implementation.getInterfaces().contains(node)) .filter(Directives::isMappedType)
if (type.getInterfaces().isEmpty()) { out.format("type %s%s {\n", type.getName(), directivesString(GraphQLObjectType.class, type.getDirectives())); } else { Comparator<? super GraphQLType> implementsComparator = options.comparatorRegistry.getComparator(environment); Stream<String> interfaceNames = type.getInterfaces() .stream() .sorted(implementsComparator)