In a GraphQL server, what is the best practice for triggering a subscription event from data received that needs to be parsed first?

In a GraphQL server, what is the best practice for triggering a subscription event from data received that needs to be parsed first?


0

Example:

I receive data in a string that needs to be parsed first, for example an IoT message.

I can create a mutation for that no problem, I’m just storing a string in a DB, however, based on what was in the string, I then save data of very different types, so I will have a switch statement in the resolver.

If I save directly to the DB, it will not trigger a subscription.

If I save via calling the type’s mutation (so calling a mutation within a mutation of the same schema), then it will trigger a subscription in my application, which is the desired effect.

Is this bad practice? Is there a better, recommended way of doing this?


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *