Draft
Conversation
BCerki
commented
Mar 3, 2022
Comment on lines
+29
to
+30
| //@ts-ignore | ||
| const input = document.getElementById("newTodo").value |
Author
There was a problem hiding this comment.
Any suggestions for how to do this better?
There was a problem hiding this comment.
you could
- register an
onChange={(event) => doSomething(event.target.value)}on the input field, to keep an always up-to-date state - or better, wrap the whole thing in a
<form onSubmit={handleSubmit}>, the submit click event should have an array of elements as a target where you can retrieve your data
pbastia
reviewed
Mar 3, 2022
| function TodoList(props: Props) { | ||
|
|
||
| const data = useFragment( | ||
| // underscore matches prop name, convention in this project to use _query if its of type Query (type comes from postgraphile) |
There was a problem hiding this comment.
I think Relay will enforce the name of the fragment starting with your default export's name, and ending with your data type (Query, Todo, etc. )
pbastia
reviewed
Mar 3, 2022
| updateTodo(input: $input) { | ||
| todoEdge { | ||
| node { | ||
| completed |
There was a problem hiding this comment.
you'll need to fetch the id here, for Relay to update its local store
https://relay.dev/docs/guided-tour/updating-data/graphql-mutations/#updating-data-once-a-request-is-complete
This way if the request fails, the checkbox will uncheck itself on re-render
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.