feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.07k stars 752 forks source link

feat(schema): Virtual property resolvers #2900

Closed daffl closed 1 year ago

daffl commented 1 year ago

This pull request implements virtual property resolvers as discussed in https://github.com/feathersjs/feathers/issues/2821 and allows selecting all fields - including property resolvers - using the $select query syntax and ensures that databases only get the $select fields they care about. A virtual resolver is essentially a property resolver but does not have a value:

import { resolve, virtual } from '@feathersjs/schema'

const messageResolver = resolve<Message, HookContext>({
  user: virtual(async (message, context) => {
    // Associate the user that sent the message
    return context.app.service('users').get(message.userId)
  })
})

Should close https://github.com/feathersjs/feathers/issues/2595 but we'll leave https://github.com/feathersjs/feathers/issues/2821 open to look at defining dependencies and https://github.com/feathersjs/feathers/issues/2604 to see if something more than $select is needed.

netlify[bot] commented 1 year ago

Deploy Preview for feathers-dove ready!

Name Link
Latest commit 2380b6139f8a66e978b710d0a407b13a46487e19
Latest deploy log https://app.netlify.com/sites/feathers-dove/deploys/6385690c54daea0009c1388e
Deploy Preview https://deploy-preview-2900--feathers-dove.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.