-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: data engine refactoring #115
Conversation
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.
The technical parts of this PR looks good, it makes sense to keep the React API separate from the internals.
While it's nice to have the imperative API ready, we need to have documentation for the intended use case for it so we don't start to overuse it early and lose the benefits of declaring data up front. That would put the data engine more along the lines of D2 which was easy to leak throughout an applications architecture.
Stating the technology as "Javascript" in the matrix for the Data Engine and Data Engine Links layers should be "Typescript".
All in all I'm OK with this, I think it is time that we start applying it in the "real world" before extending it further. Especially in the refactored Maintenance app as if the Data Engine cannot deal with those use cases, then it limits its utility in the wild.
One of the most popular type of apps that is built by external developers is a maintenance app specific for their metadata and criteria.
children, | ||
}: MutationInput) => { | ||
const mutationState = useDataMutation(mutation, { | ||
onCompleted, |
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.
Why choose onCompleted
over onComplete
?
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.
🤷♂ I'd usually prefer on<verb>
, but this came from Apollo Client which uses onCompleted
for this exact case. Our react hooks API is almost identical to Apollo's at the moment, which I think is a nice feature. Do you think it should be onComplete
?
If we want full parity another consideration is whether to use client
instead of engine
- I prefer engine
there though I think.
I disagree with this - the source is typescript, but the output is javascript and those layers can be consumed in any javascript context, rather than a react context. There is no dependency on typescripts for the consumer. |
Fair enough, I took the matrix as internal docs, not external so when using the matrix as a map for the review it stuck out as odd to me. |
Changed to |
I agree wholeheartedly with using this in "real world", but I might urge caution in rushing to battle with maintenance-app and its variants. We can (and possibly should) provide a metadata-specific API for DHIS-heavy things (a la D2 schemas, though obviously take that comparison with a grain of salt), so trying to implement maintenance tools around a low-level data access API might lead us to "extend it further" too early. Even though there have been some 3rd party metadata management tools, I would argue actually that this is a special case of app, rather than the status quo. |
@varl renamed |
If approved I'll add docs and merge to |
The Maintenance App Refactor is a good candidate for that reason -- there's no real timeline to getting it "done" and retire the old maintenance app, so it is not strictly the "real world", but close enough to work as proving grounds. |
I would've preferred if this merge happened after the meeting (as I've had some questions). |
@Mohammer5 it's merged to the |
@Mohammer5 questions and changes still definitely welcome! I think it’s probably easier to iterate on the next branch than to discuss smaller parts of this large Pr, but if you disagree or think the overall refactor has fundamental issues I can also revert this or just not merge the next branch to master.
Envoyé de mon iPhone
… Le 16 sept. 2019 à 13:39, Viktor Varland ***@***.***> a écrit :
@Mohammer5 it's merged to the next branch, there is still time for questions and changes before it is merged to master.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@amcgee Thanks, I'll wait for the meeting before I comment on this one |
* feat: data engine refactoring (#115) * feat: support network request aborting * fix: also include alert() in DataQuery renderprop * fix: don't expose imperative abort, refactor useDataQuery * feat: add ability to refetch data, upgrade react, tests * chore: run yarn autoclean for all type deps * feat: implement mutation hook * feat: add Mutation component and remove support for concurrent mutations * chore: mutation tests and bugfix * chore: fix bad merge * feat: add support for variables, callbacks, multiple mutations, and more * chore: refactor internals * fix: update fetchData call to use object parameter * fix: remove unnecessary immediate check * chore: update mutation static input label * feat: initial overhaul commit * chore: fix bugs, all tests pass, example works * chore: full test coverage * feat: add engine output to hooks, update component wrappers * chore: fix tests * chore: update types reference * chore: fix capitalization typo * chore: build before testing * chore: export useDataEngine, move dev deps to root * chore: rename onCompleted to onComplete * chore: don't collect coverage from reexport index * chore: re-indent package.json
This pull request is a major overhaul of the internal architecture of the data service. It supersedes both #66 and #102
The following are accomplished in this PR:
useDataEngine
hook to get direct access to the engine which supports.query
and.mutation
methodsengine
prop to the response objects of bothuseDataQuery
anduseDataMutation
, to ensureuseDataQuery
(from feat: add support for mutations #66)resource
field)These are the things I like about this change:
engine
which can be used outside of React component bodies (note: the engine still needs to originate from a React context, it is not a singleton by design)Things I don't love about this change:
DataProvider
,useDataQuery
,useDataEngine
,useDataMutation
,CustomDataProvider
engine.query()
,engine.mutate()
CustomDataLink
,RestAPILink
,CacheLink
(future)These layers are functionally isolated in code, so there aren't any cross-layer imports (except a few Typescript types). We could split out the engine and links to separate repositories, but that will just increase the complexity at this point so I think we should defer that move until we have a reason to use the engine stand-alone.
TODO