MCPcopy
hub / github.com/pocketbase/pocketbase / NewRecordFieldResolver

Function NewRecordFieldResolver

core/record_field_resolver.go:85–127  ·  view source on GitHub ↗

NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`.

(
	app App,
	baseCollection *Collection,
	requestInfo *RequestInfo,
	allowHiddenFields bool,
)

Source from the content-addressed store, hash-verified

83
84// NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`.
85func NewRecordFieldResolver(
86 app App,
87 baseCollection *Collection,
88 requestInfo *RequestInfo,
89 allowHiddenFields bool,
90) *RecordFieldResolver {
91 r := &RecordFieldResolver{
92 app: app,
93 baseCollection: baseCollection,
94 requestInfo: requestInfo,
95 allowHiddenFields: allowHiddenFields, // note: it is not based only on the requestInfo.auth since it could be used by a non-request internal method
96 joins: []*search.Join{},
97 allowedFields: []string{
98 `^\w+[\w\.\:]*$`,
99 `^\@request\.context$`,
100 `^\@request\.method$`,
101 `^\@request\.auth\.[\w\.\:]*\w+$`,
102 `^\@request\.body\.[\w\.\:]*\w+$`,
103 `^\@request\.query\.[\w\.\:]*\w+$`,
104 `^\@request\.headers\.[\w\.\:]*\w+$`,
105 `^\@collection\.\w+(\:\w+)?\.[\w\.\:]*\w+$`,
106 },
107 }
108
109 r.staticRequestInfo = map[string]any{}
110 if r.requestInfo != nil {
111 r.staticRequestInfo["context"] = r.requestInfo.Context
112 r.staticRequestInfo["method"] = r.requestInfo.Method
113 r.staticRequestInfo["query"] = r.requestInfo.Query
114 r.staticRequestInfo["headers"] = r.requestInfo.Headers
115 r.staticRequestInfo["body"] = r.requestInfo.Body
116 r.staticRequestInfo["auth"] = nil
117 if r.requestInfo.Auth != nil {
118 authClone := r.requestInfo.Auth.Clone()
119 r.staticRequestInfo["auth"] = authClone.
120 Unhide(authClone.Collection().Fields.FieldNames()...).
121 IgnoreEmailVisibility(true).
122 PublicExport()
123 }
124 }
125
126 return r
127}
128
129// @todo think of a better a way how to call it automatically after BuildExpr
130//

Callers 15

wantsMFAFunction · 0.92
expandFetchFunction · 0.92
autoResolveRecordsFlagsFunction · 0.92
recordsListFunction · 0.92
recordViewFunction · 0.92
recordCreateFunction · 0.92
recordUpdateFunction · 0.92

Calls 6

PublicExportMethod · 0.80
IgnoreEmailVisibilityMethod · 0.80
UnhideMethod · 0.80
FieldNamesMethod · 0.80
CollectionMethod · 0.80
CloneMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…