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

Clean Code: DataServices #897

Closed
robertu7 opened this issue Apr 8, 2020 · 5 comments · Fixed by #2142
Closed

Clean Code: DataServices #897

robertu7 opened this issue Apr 8, 2020 · 5 comments · Fixed by #2142
Assignees
Labels
enhancement New feature or request

Comments

@robertu7
Copy link
Contributor

robertu7 commented Apr 8, 2020

DataServices such as userService.ts and articleService.ts have a lot of code in a single file, and as our business logic grows, they become difficult to maintain.

@devformatters
Copy link
Contributor

The original design of service is only about data and sql operation. In my view, the business logic should always stay in resolver instead of service.

@guoliu guoliu added the enhancement New feature or request label Aug 3, 2020
@guoliu
Copy link
Contributor

guoliu commented Aug 3, 2020

The original design of service is only about data and sql operation. In my view, the business logic should always stay in resolver instead of service.

Agreed. Data services are used as data sources of Apollo Server, so we should just expose connections to external services such as database, queue, s3, etc., and leave everything else in resolvers.

@guoliu guoliu added this to To do in Enhancements & Bugs via automation Aug 12, 2020
@guoliu guoliu moved this from To do to Brainstorm in Enhancements & Bugs Sep 18, 2020
@devformatters devformatters added this to Brainstrom in 🚀 Dev Oct 6, 2020
@robertu7
Copy link
Contributor Author

#1628

@devformatters devformatters moved this from Brainstrom to In progress in 🚀 Dev Jan 6, 2021
@devformatters devformatters self-assigned this Jan 6, 2021
@devformatters devformatters moved this from Brainstorm to In progress in Enhancements & Bugs Jan 6, 2021
@robertu7 robertu7 linked a pull request Jul 14, 2021 that will close this issue
Enhancements & Bugs automation moved this from In progress to Done Jul 14, 2021
@devformatters devformatters moved this from In progress to Done in 🚀 Dev Jul 15, 2021
@devformatters
Copy link
Contributor

Nice PR #2142 💪🏻

@gary02
Copy link
Contributor

gary02 commented Mar 5, 2024

the business logic should always stay in resolver instead of service.

But this way makes writing unit tests harder.

Furthermore, sometime, same business logics are needed by multi resolvers. Services are good places to store those business logic for reuse in such case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants