Skip to content

Instantly share code, notes, and snippets.

@JoviDeCroock
Created March 25, 2021 15:49
Show Gist options
  • Save JoviDeCroock/0a612c2728e799f1562a49e106d71a3b to your computer and use it in GitHub Desktop.
Save JoviDeCroock/0a612c2728e799f1562a49e106d71a3b to your computer and use it in GitHub Desktop.
urql-test
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} />
}
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