Add_graft not adding to context

It’s looking to me like my Oban.Pro.Workflow.add_graft is not adding to context, but in the docs it does

def new_workflow do
    Workflow.new()
    |> Workflow.put_context(context)
    |> Workflow.add_graft(:foo, &graft_foo/1)
    |> Workflow.add_cascade(:bar, &bar/1, deps: [:foo])
    |> Oban.insert_all()
end

def graft_foo(_) do
    Workflow.new()
    |> Workflow.add(:foo_id, foo_worker)
    |> Workflow.apply_graft()
    |> Oban.insert_all()
end

def bar(context) do
  %{foo: _} = context

  # ...
end

foo will not be in the context…

Confirmed that this is an issue with v1.6.0 (proper). Will have a fix soon for v1.6.1. Thanks for the report, as always :slightly_smiling_face:

1 Like

With 1.6.1, it’s in the next add_cascade, but not in the next add_graft. It has reverted back to the original context again.

Will you share a minimal example that shows what you’re expecting, so we’re definitely talking about the same code?

No, this one was my fault.

I didn’t realize you need to add it to deps for the context to be merged. I only had the step I was waiting on,

e.g. step 3 waits on 2 and step 2 waits on 1.
If I want context from 1 and 2 in step 3, even if I technically only need to wait on 2, I still need to add both as deps to step 3.

1 Like

it appears as though the context is not passing through the grafts in tests though

I’m using the run_workflow/2 function in tests

None of the context is passing through? Can you share a minimal code example to demonstrate?

Testing with run_workflow/1 is how we’re verifying this functionality, so it’s surprising to hear that it’s working differently for you.

looks like the same ones missing from earlier

i’m skipping the tests for now. it works as intended manually testing the application

will dig in deeper at another time