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
-`properties`: An object of property names and their [resolver functions](#property-resolvers)
80
-
-`converter` (optional): A `async (data, context) => {}` function that can return a completely new representation of the data. A `converter` runs before `properties` resolvers.
81
-
82
73
## Property resolvers
83
74
84
-
A resolver function is an `async` function that resolves a property on a data object. If it returns `undefined` the property will not be included. It gets passed the following parameters:
75
+
Property resolvers are a map of property names to resolver functions. A resolver function is an `async` function that resolves a property on a data object. If it returns `undefined` the property will not be included. It gets passed the following parameters:
85
76
86
77
-`value` - The current value which can also be `undefined`
87
78
-`data` - The initial data object
@@ -90,15 +81,13 @@ A resolver function is an `async` function that resolves a property on a data ob
@@ -109,6 +98,36 @@ Property resolver functions should only return a value and not have side effects
109
98
110
99
</BlockQuote>
111
100
101
+
## Options
102
+
103
+
A resolver takes the following options as the second parameter:
104
+
105
+
-`converter` (optional): A `async (data, context) => {}` function that can return a completely new representation of the data. A `converter` runs before `properties` resolvers.
// Convert the raw data into a new structure before running property resolvers
121
+
converter: async (rawData, context) => {
122
+
return {
123
+
firstName: rawData.data.first_name,
124
+
lastName: rawData.data.last_name
125
+
}
126
+
}
127
+
}
128
+
)
129
+
```
130
+
112
131
## Hooks
113
132
114
133
In a Feathers application, resolvers are used through [hooks](../hooks.md) to convert service method query, data and responses. The context for these resolvers is always the [hook context](../hooks.md#hook-context).
0 commit comments