{"action":"created","issue":{"url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/35","repository_url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay","labels_url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/35/comments","events_url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/35/events","html_url":"https://github.com/absinthe-graphql/absinthe_relay/issues/35","id":186453988,"number":35,"title":"Boolean fields in a mutation's input type are dropped when false","user":{"login":"redjohn","id":308193,"avatar_url":"https://avatars.githubusercontent.com/u/308193?v=3","gravatar_id":"","url":"https://api.github.com/users/redjohn","html_url":"https://github.com/redjohn","followers_url":"https://api.github.com/users/redjohn/followers","following_url":"https://api.github.com/users/redjohn/following{/other_user}","gists_url":"https://api.github.com/users/redjohn/gists{/gist_id}","starred_url":"https://api.github.com/users/redjohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redjohn/subscriptions","organizations_url":"https://api.github.com/users/redjohn/orgs","repos_url":"https://api.github.com/users/redjohn/repos","events_url":"https://api.github.com/users/redjohn/events{/privacy}","received_events_url":"https://api.github.com/users/redjohn/received_events","type":"User","site_admin":false},"labels":[{"id":305718667,"url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/labels/Type:Bug","name":"Type:Bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-01T03:59:56Z","updated_at":"2016-11-01T11:36:54Z","closed_at":null,"body":"I'm working on a project where we want to supply a boolean value as a field on a mutation's input type, for example:\r\n\r\n```elixir\r\n    payload field :create_user do\r\n      input do\r\n        field :name, non_null(:string)\r\n        field :admin, non_null(:boolean)\r\n      end\r\n      output do\r\n        field :user, :user\r\n      end\r\n      resolve &Resolver.User.create/2\r\n    end\r\n```\r\n\r\nWith the Absinthe v1.2 branch (and the corresponding branch for Absinthe Relay), if the supplied value for `admin` is `false`, it gets dropped from the `args` before it gets to the resolver. I've set up an example Phoenix app to illustrat the issue. This is what is logged:\r\n\r\n```\r\n[info] POST /docs\r\n[info] Variables: %{\"input\" => %{\"admin\" => false, \"clientMutationId\" => \"0\", \"name\" => \"Not Test User\"}}\r\n[debug] GraphQL Document:\r\nmutation testing($input:CreateUserInput!) {\r\n  createUser(input:$input) {\r\n    user {\r\n      id\r\n      name\r\n      admin\r\n    }\r\n  }\r\n}\r\n\r\n[info] args for create: %{client_mutation_id: \"0\", name: \"Not Test User\"}\r\n[info] Sent 200 in 24ms\r\n```\r\n\r\nWhen I define a mutation without using any of the Relay Notation, the `admin` value is not dropped.\r\n\r\nMutation definition:\r\n```elixir\r\n    field :other_create_user, type: :user do\r\n      arg :name, non_null(:string)\r\n      arg :admin, non_null(:boolean)\r\n      resolve fn args, ctx ->\r\n        with {:ok, user} <- Resolver.User.create(args, ctx),\r\n          do: {:ok, user[:user]}\r\n      end\r\n    end\r\n```\r\n\r\nLog:\r\n```\r\n[info] POST /docs\r\n[info] Variables: %{\"admin\" => false, \"name\" => \"Not a Test User\"}\r\n[debug] GraphQL Document:\r\nmutation testing($admin: Boolean!, $name:String!) {\r\n  otherCreateUser(admin: $admin, name:$name) {\r\n    id\r\n    name\r\n    admin\r\n  }\r\n}\r\n\r\n[info] args for create: %{admin: false, name: \"Not a Test User\"}\r\n[info] Sent 200 in 167ms\r\n```\r\n\r\nAs a result, I think the issue must be somewhere inside the Absinthe Relay support. All cases work with Absinthe 1.1 and the corresponding version of Absinthe Relay. You can see my full app at https://github.com/redjohn/absinthe_relay_boolean_mutation_field. There are branches named 1.1 and 1.2 with tests that illustrate the issue.\r\n\r\nI'm willing to help fix it, but could use a pointer about where to start looking in the code. Hope this is helpful."},"comment":{"url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/comments/257545752","html_url":"https://github.com/absinthe-graphql/absinthe_relay/issues/35#issuecomment-257545752","issue_url":"https://api.github.com/repos/absinthe-graphql/absinthe_relay/issues/35","id":257545752,"user":{"login":"benwilson512","id":247817,"avatar_url":"https://avatars.githubusercontent.com/u/247817?v=3","gravatar_id":"","url":"https://api.github.com/users/benwilson512","html_url":"https://github.com/benwilson512","followers_url":"https://api.github.com/users/benwilson512/followers","following_url":"https://api.github.com/users/benwilson512/following{/other_user}","gists_url":"https://api.github.com/users/benwilson512/gists{/gist_id}","starred_url":"https://api.github.com/users/benwilson512/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benwilson512/subscriptions","organizations_url":"https://api.github.com/users/benwilson512/orgs","repos_url":"https://api.github.com/users/benwilson512/repos","events_url":"https://api.github.com/users/benwilson512/events{/privacy}","received_events_url":"https://api.github.com/users/benwilson512/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T11:36:54Z","updated_at":"2016-11-01T11:36:54Z","body":"Found the issue. It wasn't relay specific, but it was specific to input objects, which was used in the relay case and not the other cases. Basically, I was trying to filter out `nil` inputs by doing\r\n\r\n```elixir\r\n|> Enum.filter(fn {_, v} -> v end)\r\n```\r\n\r\nWhoops.\r\n\r\nNow it's\r\n```\r\n|> Enum.reject(&match?({_, nil}, &1))\r\n```\r\n\r\nWill have a fix pushed shortly, thanks!"}}
{"actor":{"display_login":"benwilson512"}}