-
Notifications
You must be signed in to change notification settings - Fork 27
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
Extract logic from application-shell
to application-shell-connector
package
#3245
Extract logic from application-shell
to application-shell-connector
package
#3245
Conversation
…l-connector package
|
Deploy preview for merchant-center-application-kit ready! ✅ Preview Built with commit d23ae2d. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the refactor!
I pushed a couple of commits to move the constants into the constants package and keep the exported types from app shell for backwards compatiblity (and clean up the deps a bit).
Thanks a lot for your help! 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor. Makes total sense. Thanks for the diagram in the description!
827e7d2
into
SHIELD-840-custom-views-selector
…r` package (#3245) * refactor: extract apollo related utilities from app-shell to app-shell-connector package * fix: lintin fixes * refactor: remove unused imports * refactor: move custom view components from app-shell to app-shell-connectors package * refactor: move constants to constants package * fix: keep export types for backwards compatibility * refactor: remove unused packages from app-shell * fix: remove unwanted depdency and fix some tests --------- Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>
* refactor(application-components): first iteration on new custom views selector component * refactor: implement custom views data fetching * refactor: implement custom views data fetching * fix(application-shell): fix types * refactor: include custom views selector in all page components * Extract logic from `application-shell` to `application-shell-connector` package (#3245) * refactor: extract apollo related utilities from app-shell to app-shell-connector package * fix: lintin fixes * refactor: remove unused imports * refactor: move custom view components from app-shell to app-shell-connectors package * refactor: move constants to constants package * fix: keep export types for backwards compatibility * refactor: remove unused packages from app-shell * fix: remove unwanted depdency and fix some tests --------- Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com> * refactor: early return if locator code is not provided * refactor: error handling * refactor: remove mocks * test(playground): add mocks and test for custom panel demo * docs: changesets * refactor: define message --------- Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>
Summary
Extract logic from
application-shell
toapplication-shell-connector
packageDescription
In the source PR (#3242) we included the new
CustomViewSelector
component in theapplication-shell
package but this leads to a circular dependency between that one and theapplication-components
package.We are ok with the former depending on the latter, but not the other way around.
The problem is that this new component (
CustomViewSelector
) is going to be used from all page components (which live in theapplication-components
packages) but it is the first one of this kind which also needs to interact with the backend API (fetch available Custom Views for an specific view locator). This means it needs access to Apollo Graphql machinery, which is implemented in theapplication-shell
package.To avoid this unwanted dependency (circular) flow, we propose to move most of the Apollo Graphql machinery to the
application-shell-connectors
packages, which is independent and can be used from both the other two (application-shell
andapplication-components
).The initial idea was to move the Apollo client factory function and the custom hooks to interact with the queries and mutations (
useMcQuery
anduseMcMutation
), but we need to drag some other modules which those ones depend on.So basically in this PR we are:
application-shell
package to theapplication-shell-connectors
one.CustomViewSelector
component and the (already existing)CustomViewSelector
(the former depends on this one fromapplication-shell
to theapplication-components
package.Here is a schema of the proposal implemented in this PR: