拨号器(通过Dialyxir)对苦艾酒(GraphQL)路线的“转发”命令发出有关“但该值不匹配”的警告。如何解决?

问题描述 投票:0回答:1

我收到有关无法比对的回报的透析器错误,我不确定该如何正确解决。

mix dialyzer --quiet
lib/my_app_web/router.ex:1:no_return
Function __checks__/0 has no local return.
________________________________________________________________________________
lib/my_app_web/router.ex:21:unmatched_return
The expression produces a value of type:

%{
  :adapter => _,
  :before_send => _,
  :content_type => _,
  :context => _,
  :document_providers => _,
  :json_codec => _,
  :log_level => _,
  :no_query_message => _,
  :pipeline => _,
  :pubsub => _,
  :raw_options => Keyword.t(),
  :schema_mod => atom(),
  :serializer => _
}

but this value is unmatched.

________________________________________________________________________________
lib/my_app_web/router.ex:24:unmatched_return
The expression produces a value of type:

%{
  :adapter => _,
  :additional_pipeline => _,
  :assets => _,
  :before_send => _,
  :content_type => _,
  :context => _,
  :default_headers => _,
  :default_url => _,
  :document_providers => _,
  :interface => _,
  :json_codec => _,
  :log_level => _,
  :no_query_message => _,
  :pipeline => {Absinthe.Plug.GraphiQL, :pipeline},
  :pubsub => _,
  :raw_options => [{_, _}],
  :schema_mod => atom(),
  :serializer => _,
  :socket => _,
  :socket_url => _
}

but this value is unmatched.

我的mix.exs看起来像这样:

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      elixir: "1.9.4",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      dialyzer: [
        plt_add_deps: :transitive,
        flags: [:error_handling, :race_conditions, :unmatched_returns, :underspecs]
      ],
      aliases: aliases(),
      deps: deps()
    ]
  end

我的router.ex看起来像这样:

defmodule MyAppWeb.Router do
  use MyAppWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
    plug MyAppWeb.Auth
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  # Other scopes may use custom stacks.
  scope "/api" do
    pipe_through :api

    forward "/graphql", Absinthe.Plug, schema: MyAppWeb.Schema.UserTypes

    if Mix.env() == :dev do
      forward "/graphiql", Absinthe.Plug.GraphiQL,
        schema: MyAppWeb.Schema.UserTypes,
        interface: :simple
    end
  end

  scope "/", MyAppWeb do
    pipe_through :browser

    resources "/users", UserController,
      only: [:index, :show, :new, :create, :edit, :delete, :update]

    resources "/sessions", SessionController, only: [:new, :create, :delete]

    get "/", PageController, :index, as: :home

    get "/*path", PageController, :index
  end
end

我已经尝试过_ =技巧,但似乎不起作用。我认为使用无与伦比的回报可能会有所帮助,但在这种情况下可能无济于事。我已经阅读了此页面(https://github.com/jeremyjh/dialyxir/wiki/Phoenix-Dialyxir-Quickstart),但我认为它没有帮助解决此问题。

任何反馈或指导将不胜感激。

谢谢

graphql elixir phoenix dialyzer absinthe
1个回答
0
投票

我发现问题来自此凤凰号提交:https://github.com/phoenixframework/phoenix/commit/b10fb7dc33a198595872b783cbbf90f1daee91ba

可能是Phoenix问题或引起警告的Absinthe.Plug.init/1规格。

对于时间问题,您可以使用Dialyxir的忽略警告功能:https://github.com/jeremyjh/dialyxir#ignore-warnings

© www.soinside.com 2019 - 2024. All rights reserved.