Replies: 2 comments
-
Wow, it's pretty wild, but not totally crazy 😆 I definitely imagined something like this with the I think it's possible. The main thing that stood out to me was allocating memory during a request that won't be GC'd when the request is done. For example,
It's not a deal-breaker -- especially if you know your customers' usage patterns well enough to know it's not a problem. Another thing is that the cached fields and methods won't be reset when customers update their custom fields. The database will have new data, but Another issue is that customers will share methods. If one customer makes a custom field called The other thing is, I'd suggest extensive unit tests and benchmarks for this part of your API. I definitely don't expect to break the APIs you're using here, but I might overlook something! (I'd be open to including some tests for this usage in the gem, too, if you want to contribute them.) Also, other internal changes might hurt performance in ways that I can't yet imagine... I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@rmosolgo Thank you for the feedback on this! Much appreciated. I hadn't thought about the GC issue with defining methods; glad you pointed that out! I had looked to see if I could use a The custom field configuration rarely changes, but I agree that change should be reflected immediately in the schema and definitely not vary between which instance is serving the request. I like the idea of a cache-busting version key, or even only caching for the duration of a request since at least in our case, the customer-facing API isn't used enough to the point where caching this would make an appreciable difference. I would expect some kind of performance penalty for doing this, but I think the tradeoff will be worth it for our customers' ease of use (and our support of them). Fortunately these days provisioning a new server means editing some k8s config :D I'll get busy turning this MVP into a production-ready solution, replete with tests to ensure there's no cross-thread or cross-request issues going on. If it all pans out, I'll be happy to submit the final results for consideration in documentation :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
A bit of quick background. Our application is multi-tenant. The vast majority of the schema is static, but customers have the option of configuring custom fields that can attach to different record types. This allows them to store data they want to see on screens and export. These fields can be a number of different data types: strings, ints, dates, attachments, money, or record references.
Until now we've worked with this in GraphQL by using union types. This works and works well for our web app, but for a user at a customer writing their own queries, the interface is terribly cumbersome. Queries end up looking like this, except even more complex to fulfil all the types:
I'd like to simplify this interface for customers using our API.
I've got a working prototype of this, but any time I'm overriding so many default methods, I feel like I may be barking up the wrong tree, so I'm hoping for some help sanity-checking this.
The strategy is generating types for a given field's parent type, and then having everything else be context-aware so fields are pulled from the database and cached for the right account.
Type Generator
Then, the types that use custom fields can add them:
The question is: am I doing something I'm going to regret? Is there something I'm missing that will cause me pain if I do this?
Beta Was this translation helpful? Give feedback.
All reactions