-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handling of API-only vs DB-only vs both fields in schemas #2573
Comments
This would also make it easier to get rid of |
This also means moving |
I think you should also do something with the |
An added benefit is that API schemas only need to be defined on the server, which lightens the client bundle a tiny bit. Also a common problem with these fields is that you need to do API calls or run other async, server-only code. There wasn't an elegant way to do this previously, you add to extend specific fields on the server but the syntax was clunky. |
I like the idea of tightly coupling Vulcan to mongodB, however I think while working in this area, we can get some of the naming conventions to revolve more around GraphQL types than MongoDB collections. |
We could even have a separate database schema to mirror the API schema and hold fields that exist in the database but not in the API, since those fields also don't need to be exposed to the client. This is also an elegant way of improving security, since you'd know there'd be no chance of a As far as naming goes, I guess we could start calling the "collection schema" the "main" schema or "common" schema maybe? |
One thing though as far as the syntax to consider is what will it look like using typescript interfaces. Implementing interfaces would help with code hinting on how your data is structured without having to reference the schema. |
In Vulcan, any field can be included in:
But currently, that distinction is not very clear, and in fact it's not even possible to declare a field to be made available through the API but not insertable in the database at all.
It's all a bit messy, so here is a proposal for a better system.
schema
object passed tocreateCollection
for any field that should be included in the database. We keep the currentcanRead
-based permission check to know whether those fields should also be made available through the API.apiSchema
object that contains fields that should only exist in the API, and not the database.There are two advantages to this approach:
Before:
After:
The text was updated successfully, but these errors were encountered: