(CompileError) invalid quoted expression

193 views Asked by At

I'm stumped trying to debug this

I'm trying to upgrade elixir from 1.7 -> 1.13 along with some dependencies. I incrementally bumped versions to get to this point.

Anyone know of any breaking changes in how absinthe does scalars?

related question. The example they give is not beginner friendly though.

escape docs

quote docs

== Compilation error in file lib/ellie_web/graphql/types/elm/docs.ex ==
** (CompileError) lib/ellie_web/graphql/types/elm/docs.ex: invalid quoted expression: %Absinthe.Blueprint.TypeReference.NonNull{errors: [], of_type: %Absinthe.Blueprint.TypeReference.List{errors: [], of_type: %Absinthe.Blueprint.TypeReference.NonNull{errors: [], of_type: {:type, [line: 4], nil}}}}

Please make sure your quoted expressions are made of valid AST nodes. If you would like to introduce a value into the AST, such as a four-element tuple or a map, make sure to call Macro.escape/1 before
    (absinthe 1.7.0) expanding macro: Absinthe.Schema.Notation.non_null/1
    lib/ellie_web/graphql/types/elm/docs.ex:4: EllieWeb.Graphql.Types.Elm.Docs.good_list/1
make: *** [bootstrap] Error 1




%Absinthe.Blueprint.TypeReference.NonNull{
    errors: [],
    of_type: %Absinthe.Blueprint.TypeReference.List{
        errors: [],
        of_type: %Absinthe.Blueprint.TypeReference.NonNull{
            errors: [],
            of_type: {:type, [line: 4], nil}
        }
    }
}

  • attempts:

[1]

  scalar :elm_docs_type, name: "ElmDocsType" do
    serialize fn string -> string end

    parse fn
      %Absinthe.Blueprint.Input.String{value: value} -> {:ok, value}
      %Absinthe.Blueprint.Input.Null{}               -> {:ok, nil}
      _                                              -> :error
    end
  end

[2]


  scalar :elm_docs_type, name: "ElmDocsType" do
    serialize(&encode/1) 
    parse(&decode/1)
  end
  @spec decode(Absinthe.Blueprint.Input.String.t()) :: {:ok, term()} | :error
  @spec decode(Absinthe.Blueprint.Input.Null.t()) :: {:ok, nil}
  defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
    {:ok, value}
  end

  defp decode(%Absinthe.Blueprint.Input.Null{}) do
    {:ok, nil}
  end

  defp decode(_) do
    :error
  end

  defp encode(value) do
    value
  end
$ cat mix.exs
...
  defp deps do
    [
      {:absinthe, "1.7.0"},
      {:absinthe_plug, "1.5.8"},
      {:absinthe_phoenix, "2.0.2"},
      {:combine, "~> 0.10"},
      {:cowboy, "~> 2.4"},
      {:dataloader, "~> 1.0.0"},
      {:distillery, "~> 2.0.10"},
      {:httpoison, "~> 1.1"},
      {:murmur, "~> 1.0"},
      {:phoenix, "~> 1.6.7"},
      {:phoenix_pubsub, "~> 2.1.1"},
      {:phoenix_ecto, "~> 4.4.0"},
      {:reverse_proxy_plug, "~> 2.1"},
      {:ecto_sql, "~> 3.0"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 3.0.0"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:phoenix_markdown, "~> 1.0"},
      {:poison, "~> 3.1"},
      {:porcelain, "~> 2.0.3"},
      {:quantum, "~> 2.2"},
      {:timex, "~> 3.0"},
      {:sweet_xml, "~> 0.6"},
      {:sentry, "~> 7.0.6"}
    ]
  end

1

There are 1 answers

0
Geoff Langenderfer On BEST ANSWER

this diff did the trick. Seems like there was an issue with the defp

-  defp good_list(type), do: non_null(list_of(non_null(type)))
-
   object :elm_docs_module do
     field :name, non_null(:string)
     field :comment, non_null(:string)
-    field :unions, good_list(:elm_docs_union)
-    field :aliases, good_list(:elm_docs_alias)
-    field :values, good_list(:elm_docs_value)
-    field :binops, good_list(:elm_docs_binop)
+    field :unions, non_null(list_of(non_null(:elm_docs_union)))
+    field :aliases, non_null(list_of(non_null(:elm_docs_alias)))
+    field :values, non_null(list_of(non_null(:elm_docs_value)))
+    field :binops, non_null(list_of(non_null(:elm_docs_binop)))
   end