How can I implement GraphQL types by ignoring interfaces out of my hands? #1331
-
Below is the class I want to create. @GraphQLIgnore
interface SimpleUserDetails : org.springframework.security.core.userdetails.UserDetails {
@GraphQLIgnore
override fun isAccountNonExpired(): Boolean = true
@GraphQLIgnore
override fun isAccountNonLocked(): Boolean = true
@GraphQLIgnore
override fun isCredentialsNonExpired(): Boolean = true
@GraphQLIgnore
override fun isEnabled(): Boolean = true
}
@Table("users")
data class User(
@Id override val id: ID = ID.Empty,
val email: String,
val name: String?,
val hashSalt: String,
val roles: List<String>,
) : Node, SimpleUserDetails {
fun posts(
@GraphQLIgnore @Autowired postRepository: PostRepository,
env: DataFetchingEnvironment
): CompletableFuture<List<Post>> {
return postRepository.findAllByAuthorId(id, env)
}
@GraphQLIgnore
override fun getUsername(): String = email
@GraphQLIgnore
override fun getPassword(): String = hashSalt
@GraphQLIgnore
override fun getAuthorities(): Collection<GrantedAuthority> = roles.map { SimpleGrantedAuthority(it) }
} Caused by: graphql.schema.validation.InvalidSchemaException: invalid schema:
object type 'User' does not implement interface 'UserDetails' because field 'isEnabled' is missing
object type 'User' does not implement interface 'UserDetails' because field 'getAuthorities' is missing
object type 'User' does not implement interface 'UserDetails' because field 'getPassword' is missing
object type 'User' does not implement interface 'UserDetails' because field 'getUsername' is missing
object type 'User' does not implement interface 'UserDetails' because field 'isAccountNonExpired' is missing
object type 'User' does not implement interface 'UserDetails' because field 'isAccountNonLocked' is missing
object type 'User' does not implement interface 'UserDetails' because field 'isCredentialsNonExpired' is missing |
Beta Was this translation helpful? Give feedback.
Answered by
dariuszkuc
Jan 1, 2022
Replies: 1 comment 1 reply
-
Hello 👋 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
wickedev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello 👋
As per the error - your class
User
implementsSimpleUserDetails
ignored interface which in turn extends theUserDetails
interface which is not ignored. You would need to also addGraphQLIgnore
annotations toUserDetails
interface (or use custom schema generator hook to customize the schema generation behavior).