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
Each time a subscription is executed the selection set for that subscription is re-run and the result sent back to the requesting client. My subscription includes fields whose resolvers require some additional state to be present in the GraphQLContext. For example, I include HTTP headers that include authentication information (such as an OIDC access token) and a session object. The access token might change for each execution since it might expire and need to be refreshed. A new session object needs to be created on each request. I realize I don't actually have HTTP headers when the subscription is executed, but I can cobble up fake headers and add the data I need.
The question is, from where can I call this code that needs to be executed on each subscription execution and how can this code modify the GraphQL context to include this information prior to the resolver(s) being called? Would I need a custom SubscriptionExecution strategy for this?
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
-
Each time a subscription is executed the selection set for that subscription is re-run and the result sent back to the requesting client. My subscription includes fields whose resolvers require some additional state to be present in the GraphQLContext. For example, I include HTTP headers that include authentication information (such as an OIDC access token) and a session object. The access token might change for each execution since it might expire and need to be refreshed. A new session object needs to be created on each request. I realize I don't actually have HTTP headers when the subscription is executed, but I can cobble up fake headers and add the data I need.
The question is, from where can I call this code that needs to be executed on each subscription execution and how can this code modify the GraphQL context to include this information prior to the resolver(s) being called? Would I need a custom SubscriptionExecution strategy for this?
Beta Was this translation helpful? Give feedback.
All reactions