You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking to make GraphQL API calls from a Yew application. I'm fairly new to Yew, so I started with functional components per the doc recommendations. I'm at the point where I'm ready to make API calls and I'm struggling to see how to cleanly manage the query lifecycle using Suspense. In React, I'd have a useQuery hook that returns {loading, error, data} and I'd inspect the values on render. In Yew, it looks to me like Suspense would handle the "loading" state, but not really help with errors vs data, and to get that far I need to restructure every component that needs to work with GraphQL. I'm guessing I overlooked something, so I'd appreciate any assistance.
The community page has some example projects with GraphQL, but as far as I can tell they all use structure components. The code looks really neat since they follow the Elm architecture and send messages for loading, error, and success. If I need to rewrite my small project to use that, I can, but I'm trying to stick to the recommendation of using functional components.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm looking to make GraphQL API calls from a Yew application. I'm fairly new to Yew, so I started with functional components per the doc recommendations. I'm at the point where I'm ready to make API calls and I'm struggling to see how to cleanly manage the query lifecycle using
Suspense
. In React, I'd have auseQuery
hook that returns{loading, error, data}
and I'd inspect the values on render. In Yew, it looks to me likeSuspense
would handle the "loading" state, but not really help with errors vs data, and to get that far I need to restructure every component that needs to work with GraphQL. I'm guessing I overlooked something, so I'd appreciate any assistance.The community page has some example projects with GraphQL, but as far as I can tell they all use structure components. The code looks really neat since they follow the Elm architecture and send messages for loading, error, and success. If I need to rewrite my small project to use that, I can, but I'm trying to stick to the recommendation of using functional components.
Beta Was this translation helpful? Give feedback.
All reactions