【问题标题】:Is there a way to use generic type <T> in graph QL?有没有办法在 graphQL 中使用泛型类型 <T>?
【发布时间】:2022-06-21 01:46:14
【问题描述】:

我正在尝试通过将 API 调用的结果应用到 Response 中的 T 内容来返回现有工作中的 API 调用结果。 我们正在尝试将其转换为 graphQL。 这是我的回应。

@Builder
@Getter
@AllArgsConstructor
public class Response<T> {
    Result response;
    T contents;
}

但是,graphqls 无法参数化泛型 T 并且无法映射。 下面是相应的错误代码。 Could not resolve type variable 'com.example.projectj.vo.Response:T' because declaring type is not parameterized: com.example.projectj.vo.Response&lt;T&gt;

public ResponseEntity<Response> getMemberList() {
        Page<MemberVo> result = memberService.getMemberList();
        return new ResponseEntity<>(Response.builder().response(Result.builder().build()).contents(result).build(), HttpStatus.OK);
    }

这是我的要求。

【问题讨论】:

    标签: graphql-java


    【解决方案1】:

    我也在寻找这个问题的答案。 如果你知道解决方案,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多