NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`.
( app App, baseCollection *Collection, requestInfo *RequestInfo, allowHiddenFields bool, )
| 83 | |
| 84 | // NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`. |
| 85 | func 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 | // |
searching dependent graphs…