Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider excluding virtual fields when inspecting #24

Open
fishtreesugar opened this issue Jan 27, 2025 · 1 comment
Open

Consider excluding virtual fields when inspecting #24

fishtreesugar opened this issue Jan 27, 2025 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@fishtreesugar
Copy link

For example, without excluding virtual fields:

defmodule TestWorkflow do
  use Pacer.Workflow

  graph do
    field :foo, virtual?: true
    field :bar, dependencies: ~w[foo]a, resolver: &__MODULE__.add1/1, default: nil
  end

  def add1(%{foo: foo}), do: foo + 1
end

Because field :foo is missing in the struct, so the inspect result looks like a map:
inspect(Pacer.Workflow.execute(%TestWorkflow{foo: 1})) => %{__struct__: TestWorkflow, bar: 2}

When exclude virtual fields manually:

defmodule TestWorkflow do
  use Pacer.Workflow
  @derive {Inspect, except: [:foo]}

  graph do
    field :foo, virtual?: true
    field :bar, dependencies: ~w[foo]a, resolver: &__MODULE__.add1/1, default: nil
  end

  def add1(%{foo: foo}), do: foo + 1
end

The inspect result is same as struct with excluded fields:
inspect(Pacer.Workflow.execute(%TestWorkflow{foo: 1})) => #TestWorkflow<bar: 2, ...>

@stelane
Copy link
Contributor

stelane commented Jan 27, 2025

@fishtreesugar Thanks for bringing this up! We have this on our backlog!

@zkayser zkayser added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants