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
Copy file name to clipboardExpand all lines: docs/plugins/resolvers.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ let myResolver = {
14
14
15
15
canRead:/^mongodb:/i,
16
16
17
-
read(file, callback) {
17
+
read(file, callback, $refs) {
18
18
MongoClient.connect(file.url, (err, db) => {
19
19
if (err) {
20
20
callback(err);
@@ -55,8 +55,7 @@ let myResolver = {
55
55
};
56
56
```
57
57
58
-
When using the function form, the `file` parameter is a [file info object](file-info-object.md), which contains information about the file being resolved.
59
-
58
+
When using the function form, the `file` parameter is a [file info object](file-info-object.md), which contains information about the file being resolved. The `$refs` parameter is a [`$Refs`](../refs.md) object, which allows your resolver to determine context (ex. `$refs._root$Ref.path` can be used to determine the relative path your resolver is operating from).
60
59
61
60
#### The `read` method
62
61
This is where the real work of a resolver happens. The `read` method accepts the same [file info object](file-info-object.md) as the `canRead` function, but rather than returning a boolean value, the `read` method should return the contents of the file. The file contents should be returned in as raw a form as possible, such as a string or a byte array. Any further parsing or processing should be done by [parsers](parsers.md).
0 commit comments