MCPcopy Index your code
hub / github.com/dagger/dagger / resolvePath

Method resolvePath

dagql/server.go:2048–2177  ·  view source on GitHub ↗
(ctx context.Context, self AnyObjectResult, sel Selection)

Source from the content-addressed store, hash-verified

2046}
2047
2048func (s *Server) resolvePath(ctx context.Context, self AnyObjectResult, sel Selection) (res any, rerr error) {
2049 defer func() {
2050 if r := recover(); r != nil {
2051 rerr = PanicError{
2052 Cause: r,
2053 Self: self,
2054 Selection: sel,
2055 Stack: debug.Stack(),
2056 }
2057 }
2058
2059 if rerr != nil {
2060 var queryPath ast.Path
2061 if recipeID, err := self.RecipeID(ctx); err == nil {
2062 queryPath = append(idToPath(recipeID), ast.PathName(sel.Name()))
2063 } else {
2064 queryPath = ast.Path{ast.PathName(sel.Name())}
2065 }
2066 rerr = gqlErr(rerr, queryPath)
2067 }
2068 }()
2069
2070 if sel.Selector.Nth != 0 {
2071 // NOTE: this is explicitly not handled - but it's fine because
2072 // resolvePath is called from selectors from field parsing, so we
2073 // shouldn't hit this in practice
2074 return nil, fmt.Errorf("cannot resolve selector path with nth")
2075 }
2076
2077 // __typename returns the concrete type name of the current object.
2078 if sel.Selector.Field == "__typename" {
2079 return self.ObjectType().TypeName(), nil
2080 }
2081
2082 leaseCtx, release, err := withOperationLease(ctx)
2083 if err != nil {
2084 return nil, fmt.Errorf("acquire operation lease: %w", err)
2085 }
2086 ctx = leaseCtx
2087 defer func() {
2088 if releaseErr := release(context.WithoutCancel(ctx)); releaseErr != nil && rerr == nil {
2089 rerr = releaseErr
2090 }
2091 }()
2092
2093 val, err := self.Select(ctx, s, sel.Selector)
2094 if err != nil {
2095 return nil, err
2096 }
2097
2098 if val == nil || val.Unwrap() == nil {
2099 // a nil value ignores all sub-selections
2100 return nil, nil
2101 }
2102
2103 enum, ok := val.Unwrap().(Enumerable)
2104 if ok {
2105 // we're sub-selecting into an enumerable value, so we need to resolve each

Callers 1

ResolveMethod · 0.95

Calls 15

ObjectTypeMethod · 0.95
SelectMethod · 0.95
loadNthValueMethod · 0.95
toSelectableMethod · 0.95
ResolveMethod · 0.95
idToPathFunction · 0.85
withOperationLeaseFunction · 0.85
gqlErrFunction · 0.70
RecipeIDMethod · 0.65
NameMethod · 0.65
TypeNameMethod · 0.65
UnwrapMethod · 0.65

Tested by

no test coverage detected