loadWorkspaceArg loads a workspace argument by resolving it through the currentWorkspace query. The workspace is automatically injected into module functions that declare a Workspace parameter.
( ctx context.Context, dag *dagql.Server, )
| 1255 | // currentWorkspace query. The workspace is automatically injected into |
| 1256 | // module functions that declare a Workspace parameter. |
| 1257 | func (fn *ModuleFunction) loadWorkspaceArg( |
| 1258 | ctx context.Context, |
| 1259 | dag *dagql.Server, |
| 1260 | ) (dagql.IDType, error) { |
| 1261 | if dag == nil { |
| 1262 | return nil, fmt.Errorf("dagql server is nil but required for workspace argument") |
| 1263 | } |
| 1264 | |
| 1265 | var ws dagql.ObjectResult[*Workspace] |
| 1266 | err := dag.Select(ctx, dag.Root(), &ws, |
| 1267 | dagql.Selector{ |
| 1268 | Field: "currentWorkspace", |
| 1269 | Args: []dagql.NamedInput{ |
| 1270 | {Name: "skipMigrationCheck", Value: dagql.Boolean(true)}, |
| 1271 | }, |
| 1272 | }, |
| 1273 | ) |
| 1274 | if err != nil { |
| 1275 | return nil, fmt.Errorf("load workspace: %w", err) |
| 1276 | } |
| 1277 | |
| 1278 | wsID, err := ws.ID() |
| 1279 | if err != nil { |
| 1280 | return nil, fmt.Errorf("get workspace ID: %w", err) |
| 1281 | } |
| 1282 | return dagql.NewID[*Workspace](wsID), nil |
| 1283 | } |
| 1284 | |
| 1285 | func (fn *ModuleFunction) applyIgnoreOnDir(ctx context.Context, dag *dagql.Server, arg *FunctionArg, value any) (any, error) { |
| 1286 | if kind := arg.TypeDef.Self().Kind; kind != TypeDefKindObject { |
no test coverage detected