0

I want to return list of interfaces with different implementations by calling query/mutation in grpahql spqr.

For this purpose I suppose I need to use @GraphQLInterface. Maybe I doing something wrong, but it not works.

I have spring-boot app 2.3.3.RELEASE with graphql-spqr-spring-boot-starter 0.0.4 There is my model:

public class ResponseDto {
    ...
    List<IValidation> validations;
}

@GraphQLInterface(name = "ValidationError", implementationAutoDiscovery = true)
public interface ValidationError {

    @GraphQLQuery(name = "message")
    String getMessage();
}

@GraphQLType(name = "SimpleError")
@AllArgsConstructor
@Getter
public enum SimpleError implements ValidationError {

    ERROR("some msg");

    private String message;
}

But when I get graphql schema there is no any info about SimpleError and field message in ValidationError.

I also tried without GraphQLType and GraphQLQuery, it not works. And I tried with no enum implementation also, same result.

Could anyone explain what I'm doing wrong?

Thank you.

  • What exactly do you want the schema to look like? Because it can't exactly follow the Java types, as enums can not implement interfaces in GraphQL. – kaqqao Jan 13 '23 at 13:34
  • Also, how are `ResponseDto` and `IValidation` related to the rest? – kaqqao Jan 13 '23 at 23:04
  • @kaqqao I have some graphQL mutation that returns ResponseDto and I want to receive result like this `... on SimpleError` I also tried to implement it with simple class not enum, it also not woking. Example of impl for no spqr https://dgraph.io/blog/post/unions-interfaces/ – Saimon White Jan 16 '23 at 09:12

0 Answers0