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 have a somewhat unique situation where we host hundreds of CRM's separately (not a true SaaS). Each CRM instance can have it's own unique entity & field structure. Each system can be queried individually for their data structure metadata, which can then be used to dynamically create a GraphQL schema per CRM instance. We use an ITypeModule to accomplish this, which will also help keep the schema up-to-date at runtime when changes are identified per CRM instance. We then use a custom resolver (along with a custom FilterInputType & SortInputType) to generate a SQL query which we then send to the individual CRM instance for processing and return a Dictionary<string, string> object.
The above works quite well. If the schema of one CRM instance changes during runtime, we can trigger the ITypeModule.TypesChanged event handler. The problem comes down to if we add/remove a CRM instance in our backend config (they live completely separately from where this HotChocolate app lives), then the HC app needs to be restarted to load the new CRM instance and trigger it's AddGraphQLServer & MapGraphQL method calls.
Currently, we accomplish this be giving each CRM instance it's own unique schema name (no two CRM instances should ever overlap), and then map a graphql endpoint to each specific CRM instance, like so:
To avoid long restart delays, I have added logic to CRMTypeModule to cache the data structure metadata locally so that we don't necessarily need to query each CRM instance again for it's metadata, so that helps plenty, but of course, I'd like to avoid the restart altogether if possible. I realize that one solution would be deploy alongside each CRM an individual instance of their HC app, and then just have a centralized YARP proxy or something to pull them altogether under one host as my desired end result, however in our current infrastructure, that's easier said than done. Right now it's just easier to have one central spot for the entire service.
Open to feedback for ways I can restructure the above HC code in a way that allows me this dynamic server registering (perhaps using different schemas wasn't the best way?).
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 have a somewhat unique situation where we host hundreds of CRM's separately (not a true SaaS). Each CRM instance can have it's own unique entity & field structure. Each system can be queried individually for their data structure metadata, which can then be used to dynamically create a GraphQL schema per CRM instance. We use an
ITypeModule
to accomplish this, which will also help keep the schema up-to-date at runtime when changes are identified per CRM instance. We then use a custom resolver (along with a customFilterInputType
&SortInputType
) to generate a SQL query which we then send to the individual CRM instance for processing and return aDictionary<string, string>
object.The above works quite well. If the schema of one CRM instance changes during runtime, we can trigger the
ITypeModule.TypesChanged
event handler. The problem comes down to if we add/remove a CRM instance in our backend config (they live completely separately from where this HotChocolate app lives), then the HC app needs to be restarted to load the new CRM instance and trigger it'sAddGraphQLServer
&MapGraphQL
method calls.Currently, we accomplish this be giving each CRM instance it's own unique schema name (no two CRM instances should ever overlap), and then map a graphql endpoint to each specific CRM instance, like so:
To avoid long restart delays, I have added logic to
CRMTypeModule
to cache the data structure metadata locally so that we don't necessarily need to query each CRM instance again for it's metadata, so that helps plenty, but of course, I'd like to avoid the restart altogether if possible. I realize that one solution would be deploy alongside each CRM an individual instance of their HC app, and then just have a centralized YARP proxy or something to pull them altogether under one host as my desired end result, however in our current infrastructure, that's easier said than done. Right now it's just easier to have one central spot for the entire service.Open to feedback for ways I can restructure the above HC code in a way that allows me this dynamic server registering (perhaps using different schemas wasn't the best way?).
Beta Was this translation helpful? Give feedback.
All reactions