graphql-elixir / graphql

GraphQL Elixir
Other
859 stars 47 forks source link

List input type #45

Closed Bockit closed 8 years ago

Bockit commented 8 years ago

I'm having trouble with the list input type. Here's my root schema, you can ignore the query part, I'm only doing list inputs with the mutation. You can see I have the mutation field createTransaction. Here's where I define the createTransaction mutation field and I've highlighted where I'm defining the list type input arg.

If I run the following query:

http://127.0.0.1:4000/api?query=mutation+named{createTransaction(timestamp:timeitself,amount:50.0,description:hello,tags:[a,b,c]){amount}}

I get the following error:

[error] #PID<0.911.0> running BudgetApi.Endpoint terminated
Server: 127.0.0.1:4000 (http)
Request: GET /api?query=mutation%20named{createTransaction(timestamp:timeitself,amount:50.0,description:hello,tags:[a,b,c]){amount}}
** (exit) an exception was raised:
    ** (KeyError) key :value not found in: %{kind: :ListValue, loc: %{start: 0}, values: [%{kind: :EnumValue, loc: %{start: 0}, value: "a"}, %{kind: :EnumValue, loc: %{start: 0}, value: "b"}, %{kind: :EnumValue, loc: %{start: 0}, value: "c"}]}
        lib/graphql/execution/executor.ex:202: GraphQL.Execution.Executor.value_from_ast/3
        lib/graphql/execution/executor.ex:189: anonymous fn/4 in GraphQL.Execution.Executor.argument_values/3
        (stdlib) lists.erl:1262: :lists.foldl/3
        lib/graphql/execution/executor.ex:110: GraphQL.Execution.Executor.resolve_field/4
        lib/graphql/execution/executor.ex:91: anonymous fn/5 in GraphQL.Execution.Executor.execute_fields/4
        (stdlib) lists.erl:1262: :lists.foldl/3
        lib/graphql/execution/executor.ex:60: GraphQL.Execution.Executor.execute_operation/3
        lib/graphql/plug/endpoint.ex:44: GraphQL.Plug.Endpoint.execute/3
        (phoenix) lib/phoenix/router/route.ex:157: Phoenix.Router.Route.forward/4
        (budget_api) lib/phoenix/router.ex:255: BudgetApi.Router.dispatch/2
        (budget_api) web/router.ex:1: BudgetApi.Router.do_call/2
        (budget_api) lib/budget_api/endpoint.ex:1: BudgetApi.Endpoint.phoenix_pipeline/1
        (budget_api) lib/plug/debugger.ex:93: BudgetApi.Endpoint."call (overridable 3)"/2
        (budget_api) lib/phoenix/endpoint/render_errors.ex:34: BudgetApi.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

If I were to guess, I'd say the executor isn't aware of the listValue kind having the values key instead of value but I don't know for sure.

As an aside, are list input strings (and strings in general) supposed to have quotes around the values? Just noticing in that output it looks like it's saying the a b and c are EnumValues.

Thanks for your time.