FieldSpec looks up a field spec by name for the given view.
(name string, view call.View)
| 111 | |
| 112 | // FieldSpec looks up a field spec by name for the given view. |
| 113 | func (iface *Interface) FieldSpec(name string, view call.View) (FieldSpec, bool) { |
| 114 | iface.fieldsL.Lock() |
| 115 | defer iface.fieldsL.Unlock() |
| 116 | versions, ok := iface.fields[name] |
| 117 | if !ok { |
| 118 | return FieldSpec{}, false |
| 119 | } |
| 120 | for i := len(versions) - 1; i >= 0; i-- { |
| 121 | f := versions[i] |
| 122 | if f.MinVersion == "" || f.MinVersion == view { |
| 123 | return f.FieldSpec, true |
| 124 | } |
| 125 | } |
| 126 | return FieldSpec{}, false |
| 127 | } |
| 128 | |
| 129 | // ParseField parses an AST field selection against this interface's field specs. |
| 130 | // This is used when a query selects fields on an interface-typed return value. |