You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
type User{
id: ID!
firstName: String
lastName: String
email: String
roles: [Role!]
birthDate: Date
}
type Query {
userByEmail(email:String): User
}
query resolver
@Component
@RequiredArgsConstructor
public class UserQueryResolver implements GraphQLQueryResolver {
private final IUserRepository userRepository;
public User userByEmail(String email) {
return userRepository.findByEmail(email).orElse(null);
}
}
resolver
@Component
@RequiredArgsConstructor
@Slf4j
public class UserResolver implements GraphQLResolver<User> {
public CompletableFuture<List<Role>> roles(User user, DataFetchingEnvironment dfe) {
final DataLoader<Long, List<Role>> dataloader = dfe.getDataLoaderRegistry().getDataLoader("userRoleDataLoader");
return dataloader.load(user.getId(), user);
}
}
Everything works well on my application but I could not integrate filtering on subfields. When I am setting the User type on schema like:
type User{
id: ID!
firstName: String
lastName: String
email: String
roles(take: Int): [Role!]
birthDate: Date
}
DataFetchingEnvironment dfe will be null. How to I do filtering on subfield?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to filtering on subfield with graphql-java-kickstart.
Example query:
Here is my codes:
schema
type Query {
userByEmail(email:String): User
}
query resolver
resolver
Everything works well on my application but I could not integrate filtering on subfields. When I am setting the User type on schema like:
Beta Was this translation helpful? Give feedback.
All reactions