Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use dependency injection in query #3

Open
FLXT-Qi opened this issue Jan 2, 2020 · 2 comments
Open

Cannot use dependency injection in query #3

FLXT-Qi opened this issue Jan 2, 2020 · 2 comments

Comments

@FLXT-Qi
Copy link

FLXT-Qi commented Jan 2, 2020

For example, I create a class QueryImpl, as below.
@Component class QueryImpl implements Query { @Autowired private DatabaseService db; }

the db is null, spring cannot inject beans into the query.

@murtuza-ranapur
Copy link

Facing the same issue
@Component public class Query implements QueryRoot { @Autowired private UserService userService; }

getting null userService

@yarinvak
Copy link
Owner

yarinvak commented Jan 6, 2020

Yes i was able to reproduce the error. I am trying to figure out how to solve this. Anyway the better way of handling fields is with data fetchers - create a separate class annotated with component and you can inject the service there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants