Better handling of API-only vs DB-only vs both fields in schemas
See original GitHub issueIn Vulcan, any field can be included in:
- the database
- the API
- both
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.
- We keep the existing
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. - We support a new
apiSchema
object that contains fields that should only exist in the API, and not the database.
There are two advantages to this approach:
- We are able to distinguish between the two kinds of fields.
- We can simplify the syntax for API-only fields:
Before:
const schema = {
pagePath: {
type: String,
optional: true,
canRead: ["guests"],
resolveAs: {
typeName: "String",
resolver: (post, args, context) => {
return getPostPageLink(post, false);
},
}
}
After:
const apiSchema = {
pagePath: {
typeName: "String",
resolver: () => {...},
},
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
The Do's and Don'ts for your schema and GraphQL operations
Learn GraphQL with Apollo Odyssey, our hands-on training and tutorial course platform - https://odyssey.apollographql.com/Learn from our ...
Read more >The Do's and Don'ts for your Schema and GraphQL Operations
Presented by Michael Watson, Customer Success Engineer, ApolloLearn best practices for your GraphQL schema and client operations.
Read more >warthog - npm
With Warthog, set up your data models and resolvers, and it does the rest. ... Generate typescript classes and GraphQL schema yarn warthog ......
Read more >Using Rails for API-only Applications - Ruby on Rails Guides
Handled at the middleware layer: Reloading: Rails applications support transparent reloading. This works even if your application gets big and restarting the ...
Read more >Content management in Next.js with Sanity CMS
Editing the Sanity.io schemas. Schemas are at the core of structured content modeling in Sanity.io and refer to the field types that a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This also means moving
relation
out ofresolveAs
, which probably makes sense anyway.Blog post WIP: https://medium.com/@sachagreif/vulcan-1-16-apischema-dbschema-7a85655dca26