Closed erDuo10 closed 9 months ago
@vojtapol , I have this problem too.
Is there any hack method to fix this problem?
My schema looks like this:
type ActivityLog {
id: ID
name: String
eventTime: DateTime
attachments: CommonAttachment
}
type Case {
id: ID
number: String
attachments: [CommonAttachment]
}
@erDuo10 @foresx Did you get any resolution for this?
Here's a working example:
class TempTest {
@Test
fun test() {
val schema = SchemaParser.newParser()
.resolvers(Query())
.dictionary(Book::class)
.dictionary(Author::class)
.schemaString(
"""
union SearchResult = Book | Author
type Page {
content: [SearchResult]
}
type Book{
id: ID!
title: String!
}
type Author {
id: ID!
firstName: String!
}
type Query {
findAllBooks(skip: Int = 0, first: Int = 0) : Page!
findAllAuthors(skip: Int = 0, first: Int = 0) : Page!
}
""")
.build()
.makeExecutableSchema()
}
data class Page<T : SearchResult>(val content: List<T>)
data class Book(val id: String, val title: String) : SearchResult
data class Author(val id: String, val firstName: String) : SearchResult
sealed interface SearchResult
class Query : GraphQLQueryResolver {
fun findAllBooks(skip: Int?, first: Int?): Page<SearchResult> = Page(listOf(Book("1", "asdja")))
fun findAllAuthors(skip: Int?, first: Int?): Page<SearchResult> = Page(listOf(Author("1", "asdasd")))
}
}
java code
schema code