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 }) {idtitlecreated_atis_completedis_publicuser {name}}}
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.
Don't be surprised to see results being empty. You haven't added any todos yet! This query is just to ensure if everything works as expected.
Let's now integrate this graphql query into our react native app.
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs