简体   繁体   English

默认类型解析器无法为 GraphQL 类型`ArrayList 找到合适的 Java 类型。 提供一个@DgsTypeResolver。`

[英]The default type resolver could not find a suitable Java type for GraphQL type `ArrayList. Provide a @DgsTypeResolver.`

I have a java - Spring Boot project using graphql and DGS from.netflix.我有一个 java - Spring 启动项目,使用 graphql 和 DGS from.netflix。 I have the following query:我有以下查询:

type Query {
ticketingHistory(ticketId: String): TicketingHistory
}

interface TicketingHistory {
ticketId: String
createdOn: String
}
type TicketingEmail implements TicketingHistory {
ticketId: String
createdOn: String
emailId: String
processInstanceId: String
createdBy: EmailCreatedBy
mailFrom: String
to: String
cc: String
bcc: String
messageId: String
messageInReplyTo: String
messageReferences: String
subject: String
messagePlain: String
messageHtml: String
}
type TicketingComment implements TicketingHistory {
ticketId: String
commentId: String
userId: String
createdOn: String
taskId: String
message: String
}

and the data fetcher:和数据获取器:

@DgsComponent
@RequiredArgsConstructor
@Slf4j
public class TicketingHistoryDataFetcher {

    private final EmailService emailService;
    private final ProcessInstanceService processInstanceService;

    @DgsQuery
    public List<? extends TicketingHistory> ticketingHistory(@InputArgument String ticketId) {
        List<TicketingHistory> ticketingHistories = new ArrayList<>();
        final Set<Email> emails = emailService.findAll(ticketId);
        final List<CommentDTO> comments = processInstanceService.getComments(ticketId);

        emails.stream()
                .filter(Objects::nonNull)
                .forEach(email -> ticketingHistories.add(ticketingEmail(email)));
        comments.stream()
                .filter(Objects::nonNull)
                .forEach(comment -> ticketingHistories.add(ticketingComment(comment, ticketId)));
        ticketingHistories.sort(Comparator.comparing(TicketingHistory::getCreatedOn));

        return ticketingHistories;
    }
}

when calling it from postman and debugging it I can see that this query is called and I am getting the data but at the moment when it tries to return the list it is failing with:当从 postman 调用它并调试它时,我可以看到调用了这个查询并且我正在获取数据但是在它尝试返回失败的列表时:

com.netflix.graphql.dgs.exceptions.InvalidTypeResolverException: The default type resolver could not find a suitable Java type for GraphQL type `ArrayList. Provide a @DgsTypeResolver.`

It looks like Resolver is missing.看起来 Resolver 不见了。 Check if you have TicketingEmail and TicketingComment classes (Should be spelled the same as the type name as per the doc) Or you should have a resolver (refer to below doc for sample resolver).检查您是否有 TicketingEmail 和 TicketingComment 类(根据文档,拼写应与类型名称相同)或者您应该有一个解析器(请参阅下面的文档以获取示例解析器)。 https:/.netflix.github.io/dgs/advanced/type-resolvers-for-abstract-types/ https:/.netflix.github.io/dgs/advanced/type-resolvers-for-abstract-types/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数组列表。 按商品类型按商品名称访问 - ArrayList. Access to name by article by product type 找不到响应 object 类型的 MessageBodyWriter:java.util.ArrayList 媒体类型:text/html - 在 Resteasy 中 - Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html - in Resteasy RestEasy:找不到类型的响应对象的MessageBodyWriter:java.util.Array媒体类型列表:application / json - RestEasy: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json Java ArrayList接口类型 - Java ArrayList Interface Type Java 按类型返回 ArrayList - Java return ArrayList by type 填充 arraylist。 Java - Filling an arraylist. Java 当我尝试将数据库值保存在 ArrayList 中时,键入 Mismatch。 如何避免? - Type Mismatch when I try to save the database values in an ArrayList. How to avoid it? Java ArrayList类型问题 - Java ArrayList type issue 接口类型的 Java ArrayList - Java ArrayList of type Interface 无法写入请求:找不到适合请求类型和内容类型的HttpMessageConverter [application / x-java-serialized-object] - Could not write request: no suitable HttpMessageConverter found for request type and content type [application/x-java-serialized-object]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM