#Hi @Erik Sipsma , I was just trying out
1 messages · Page 1 of 1 (latest)
yeah, I hacked it a bit, and now it works:
Field: "cacheVolume",
Args: []dagql.NamedInput{
{
Name: "key",
Value: dagql.NewString(key),
},
},
})
if err != nil {
return inst, err
}
ctx = dagql.AddNewIdToContext(ctx, id)
return dagql.NewInstanceForCurrentID(ctx, s.srv, parent, c)```
calling `IDFor` with new selector and then adding it to ctx.
but I am not entirely sure if this is right way. what do you think
oh this one looks better:
// InstanceWithNewSelector creates a new Instance that's set to the ID calculated using new selector.
//
// This is useful in scenarios where we want to inject something into the selector
// automatically without exposing it to the user. e.g. namespacing of the selector
func InstanceWithNewSelector[P, T Typed](
ctx context.Context,
srv *Server,
parent Instance[P],
self T,
sel Selector,
) (Instance[T], error) {
id, err := parent.IDFor(ctx, sel)
if err != nil {
return Instance[T]{}, err
}
return NewInstanceForCurrentID(idToContext(ctx, id), srv, parent, self)
}
I think that makes sense, though I'll have to see it in context to tell if there's anything simpler. If it works it works though 😎