Assuming you already have a GraphQL endpoint set up and a React application with apollo-client
installed, you can query for a list of todos using the following code:
495 chars29 lines
This code defines a GraphQL query GET_TODOS
that asks for the id
, title
, and completed
fields of all the todos in the listTodo
query. The useQuery
hook is used to fetch data from the server, and the returned data and status (loading
and error
) are used to render a list of todos in the UI.
gistlibby LogSnag