Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import React from 'react';
import { Query } from 'urql';
const getTodos = `
query GetTodos {
todos(limit: 10) {
id
text
isDone
}
}
`;
const TodoList = () => {
<Query query={getTodos}>
{({ executeQuery, data }) => {
if (!data) {
return null;
}
return (
<div>
<ul>
{data.todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul>
<button
onClick={() => executeQuery({ requestPolicy: 'network-only' })}
>
Refresh
</button>
</div>
);
}}
</Query>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.