Elixir graphql api not connecting to server

Is there anyway to make graphiql available when in environments other than :dev ? i.e. whenever using a staging environment. I get this message when I try to access the url in staging: {“errors”:[{“message”:“No query document supplied”}]}

router.ex

defmodule GraphqlWithAbsintheOnPhoenixWeb.Router do

  use GraphqlWithAbsintheOnPhoenixWeb, :router

  pipeline :api do

    plug :accepts, ["json"]

    plug GraphqlWithAbsintheOnPhoenixWeb.Plugs.SetCurrentUser

  end

  scope "/" do

    pipe_through :api

    forward "/api", Absinthe.Plug, schema: GraphqlWithAbsintheOnPhoenix.GraphQL.Schema

    forward "/graphiql", Absinthe.Plug.GraphiQL,

      schema: GraphqlWithAbsintheOnPhoenix.GraphQL.Schema,

      interface: :playground

   

  end




  if Mix.env() in [:dev, :test] do

    import Phoenix.LiveDashboard.Router

    scope "/" do

      pipe_through [:fetch_session, :protect_from_forgery]

      live_dashboard "/dashboard", metrics: GraphqlWithAbsintheOnPhoenixWeb.Telemetry

    end

  end

end

my server logs

[info] GET /
[debug] ** (Phoenix.Router.NoRouteError) no route found for GET / (GraphqlWithAbsintheOnPhoenixWeb.Router)
(graphql_with_absinthe_on_phoenix 0.1.0) lib/phoenix/router.ex:406: GraphqlWithAbsintheOnPhoenixWeb.Router.call/2
(graphql_with_absinthe_on_phoenix 0.1.0) lib/graphql_with_absinthe_on_phoenix_web/endpoint.ex:1: GraphqlWithAbsintheOnPhoenixWeb.Endpoint.plug_builder_call/2
(graphql_with_absinthe_on_phoenix 0.1.0) lib/plug/debugger.ex:136: GraphqlWithAbsintheOnPhoenixWeb.Endpoint.“call (overridable 3)”/2
(graphql_with_absinthe_on_phoenix 0.1.0) lib/graphql_with_absinthe_on_phoenix_web/endpoint.ex:1: GraphqlWithAbsintheOnPhoenixWeb.Endpoint.call/2
(phoenix 1.6.7) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.9.0) c:/Users/baris/Desktop/graphql-with-absinthe-on-phoenix-main/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.9.0) c:/Users/baris/Desktop/graphql-with-absinthe-on-phoenix-main/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.9.0) c:/Users/baris/Desktop/graphql-with-absinthe-on-phoenix-main/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

[info] GET /api
[debug] Processing with Absinthe.Plug
Parameters: %{}
Pipelines: [:api]
[info] Sent 400 in 29ms

Show us your GraphqlWithAbsintheOnPhoenix.GraphQL.Schema - it looks like that file is empty and has no queries defined, you must define at least an empty block I think.

You are access / not /graphiql.

1 Like

I get this error when I do Mix phx.server localhost: error 4000 SyntaxError

That post already has an answer. Did you read the posts here? Can you address what they have said?