<@ULVA73B9P> I have a React app with an Apollo/Gra...
# ask-marvin
s
@Marvin I have a React app with an Apollo/GraphQL server, and I need to incorporate real-time status updates from flows running on a Prefect 2 centralized server deployed on AWS EKS
m
It seems the initial search did not yield relevant results about real-time status updates or integrating Prefect with WebSocket subscriptions directly from the documents searched. Real-time updates for a Prefect 2.0 flow can typically be achieved by either polling the GraphQL API or by setting up a subscription if the GraphQL server supports subscriptions. Since Apollo Server supports GraphQL subscriptions, which use WebSockets under the hood, you could potentially leverage GraphQL subscriptions to listen for changes to Prefect flow runs and update your React app in real time. If you want to pursue setting up subscriptions, here are your general steps: 1. Extend your Apollo Server with custom resolvers that subscribe to Prefect flow run status changes. 2. In your Apollo client in the React app, set up subscriptions that listen to these updates. Unfortunately, I couldn't find a straightforward guide for doing this in Prefect 2.0's documentation, as the platform may still rely on polling the API or using the UI/CLI to track the state of flows. Would you like me to attempt another search or provide some Prefect 2.0 code examples that may guide you in creating a custom solution?
s
Does prefect 2 expose a websocket endpoint for streaming the events?
n
s
I am not using prefect cloud
n
ah sorry I didnt read the above carefully enough - so we've actually begun open sourcing our events system. so you can do the same thing as above but • use
PrefectEventsSubscriber
to stream / filter events programmatically • enable the flag (for now) ie
export PREFECT_EXPERIMENTAL_EVENTS=1
e.g.
šŸ™Œ 1
s
Thanks a lot! I also saw
PREFECT_API_EVENTS_STREAM_OUT_ENABLE
in the docs which is
true
by default. We are on Prefect 2.10 and looks like we have no option but to upgrade.
šŸ‘ 1
n
correct, we only recently introduced the experimental events - somewhere in 2.17 or 2.18
šŸ‘ 1