Fetch todos - query

The first graphql query you will write will be to fetch personal todos. You will need to load the todo data from the database which belongs to the logged in user. Let's define a graphql query to fetch the required data.

query getMyTodos {
todos(where: { is_public: { _eq: false} }, order_by: { created_at: desc }) {
id
title
created_at
is_completed
}
}

Try this query in GraphiQL against the application database to see what the response looks like.

Note: You need to pass the Authorization: Bearer <token> header before querying to get the results. The token is auto-filled in the UI after logging in via Auth0.

We will be generating the above query using the utility functions generated by elm-graphql in our elm app. Lets verify it for now to make sure it works as expected.

Let's dive into the elm code to fetch personal todos in our elm app.

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
Promo
footer illustration
Brand logo
© 2024 Hasura Inc. All rights reserved
Github
Titter
Discord
Facebook
Instagram
Youtube
Linkedin
graphql-handbook