Created
March 25, 2021 15:49
-
-
Save JoviDeCroock/0a612c2728e799f1562a49e106d71a3b to your computer and use it in GitHub Desktop.
urql-test
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
import { useQuery, gql } from 'urql'; | |
import { TodoListItem, TODO_LIST_ITEM_FRAGMENT } from './TodoListItem'; | |
const TODOS_QUERY = gql` | |
query { | |
todos { | |
id | |
...TodoListItemProps | |
} | |
} | |
${TODO_LIST_ITEM_FRAGMENT} | |
`; | |
const Todos = () => { | |
const [result] = useQuery({ query: TODOS_QUERY }); | |
return result.data.todos.map(x => <TodoListItem key={x.id} {...x} /> | |
} |
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
import { useQuery, gql } from 'urql'; | |
import { TodoListItem, TODO_LIST_ITEM_FRAGMENT } from './TodoListItem'; | |
export const TODO_LIST_ITEM_FRAGMENT = gql` | |
fragment TodoListItemProps on Todo { | |
text | |
completed | |
} | |
`; | |
export const TodoListItem = () => { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment