Absinthe: Warnings on OTP 20

Created on 23 May 2017  ยท  13Comments  ยท  Source: absinthe-graphql/absinthe

I get a bunch of warnings when running phoenix project with absinthe-graphql. Apparently the warnings mention files that use Absinthe.Schema.Notation or import modules that use that module. It doesn't seem to affect functionality. I tried various Phoenix/Absinthe projects from different people on Github.

==> absinthe_blog
Compiling 21 files (.ex)
warning: key :fields will be overridden in map
web/schema/types.ex:1

warning: key :fields will be overridden in map
web/schema/types.ex:1

warning: key :fields will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :name will be overridden in map
web/schema/types.ex:1

warning: key :fields will be overridden in map
web/schema/schema.ex:1

warning: key :fields will be overridden in map
web/schema/schema.ex:1

warning: key :fields will be overridden in map
web/schema/schema.ex:1

warning: key :fields will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

warning: key :name will be overridden in map
web/schema/schema.ex:1

System details:
OS: Manjaro Linux

elixir -v
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.4.4

sample project to reproduce
https://github.com/voger/graphql_tutorial

Bug

Most helpful comment

v1.3.2 is now on hex with the requisite fixes.

All 13 comments

What version of erlang?

Erlang/OTP 20 in his post. I'd think? At the bottom.

Ah my bad was on mobile and missed that. Yeah the macros apparently generate some map literals with duplicate keys, and there's a new warning for that on OTP 20. We'll look into it.

I think I discovered a misbehavior that is probably related to this. I relate it to this bug because it appeared at the same time after the update to OTP 20.

When a mutation field contains an argument with digits in its name, the server returns an error. Here is an example:

mutation CreatePost{
  createPost(
    body: "Lorem ipsum etc."
    is30OrOlder: true,
    title: "Test the boolean",
    userId: 2
  ){
    body    
      }
}

Now when I try this mutation

mutation CreatePost{
  createPost(
    body: "Lorem ipsum etc."
    is30OrOlder: true,
    title: "Test the string",
    userId: 2
  ){
    body    
      }
}

I get this error

{
  "errors": [
    {
      "message": "Duplicate argument name.",
      "locations": [
        {
          "line": 2,
          "column": 0
        }
      ]
    },
    {
      "message": "In argument \"is30OrOlder\": Expected type \"Boolean!\", found null.",
      "locations": [
        {
          "line": 2,
          "column": 0
        }
      ]
    },
    {
      "message": "Duplicate argument name.",
      "locations": [
        {
          "line": 4,
          "column": 0
        }
      ]
    },
    {
      "message": "Unknown argument \"is30OrOlder\" on field \"createPost\" of type \"RootMutationType\".",
      "locations": [
        {
          "line": 4,
          "column": 0
        }
      ]
    }
  ]
}

If I remove the number 30 or replace it with the word "thirty" the mutation proceeds as expected.

The strange thing is that in the log it seems to pass as expected

[info] POST /graphiql
[debug] ABSINTHE schema=nil variables=%{}
---
mutation CreatePost{
  createPost(
    body: "Lorem ipsum etc."
    is30OrOlder: true,
    title: "Test the boolean",
    userId: 2
  ){
    body    
      }
}
---
[info] Sent 400 in 5ms

Edit: Fixed the mish mash from various tests.

@voger I don't think this is related. The core issue, I believe, is:

Macro.underscore("is30OrOlder")         
# => "is30_or_older"

If you want is30OrOlder to work as an arg name, define the arg as :is30_or_older. We just piggyback off Elixir's Macro.underscore/1.

Also, a 400 is the GraphQL standard HTTP error code when an error occurs during validation.

@bruce
Thanks.
I had a couple of months touching that project and I recall it was working like this. Then again maybe I am wrong. I do have a weak memory.

I tried as you said and yes, it does work.

On mac, homebrew just updated to OTP 20, elixir 1.4.5 and now I'm hitting the same issue:

warning: key :fields will be overridden in map
  lib/knowledge_graph/types.ex:1

warning: key :fields will be overridden in map
  lib/knowledge_graph/types.ex:1

warning: key :fields will be overridden in map
  lib/knowledge_graph/types.ex:1

warning: key :fields will be overridden in map
  lib/knowledge_graph/types.ex:1

...

I'll see if I can get an update out today to fix.

v1.3.2 is now on hex with the requisite fixes.

Thanks for fixing this.

Hi,

We're still seeing this on OTP20, Elixir 1.5.1:

warning: key :id will be overridden in map
  web/schema/types/objects.ex:1
warning: key :id will be overridden in map
  web/schema/types/objects.ex:1

Version info:

root@27b0971914f0:/app# iex --version
Erlang/OTP 20 [erts-9.0.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

IEx 1.5.1

Relevant library versions:

โ”œโ”€โ”€ absinthe ~> 1.3.2 (Hex package)
โ”œโ”€โ”€ absinthe_plug ~> 1.3.1 (Hex package)
โ”‚   โ”œโ”€โ”€ absinthe ~> 1.3.0 (Hex package)
โ”‚   โ””โ”€โ”€ plug ~> 1.3.2 or ~> 1.4 (Hex package)
โ”œโ”€โ”€ absinthe_relay ~> 1.3 (Hex package)
โ”‚   โ”œโ”€โ”€ absinthe ~> 1.3.0 (Hex package)
โ”‚   โ””โ”€โ”€ ecto ~> 1.0 or ~> 2.0 (Hex package)
โ”‚       โ”œโ”€โ”€ db_connection ~> 1.1 (Hex package)
โ”‚       โ”œโ”€โ”€ decimal ~> 1.2 (Hex package)
โ”‚       โ”œโ”€โ”€ poison ~> 2.2 or ~> 3.0 (Hex package)
โ”‚       โ”œโ”€โ”€ poolboy ~> 1.5 (Hex package)
โ”‚       โ””โ”€โ”€ postgrex ~> 0.13.0 (Hex package)

Any ideas where to start investigating?

(Know it's a year old, but I figured I'd mention it in case anyone else lands on this issue from searching for this error message)

@joffotron I bumped into this error message as well, in my case it was because I had listed off the id field when defining my type while using absinthe_relay, i.e:

defmodule MyProjectWeb.Schema.Types do
  use Absinthe.Schema.Notation
  use Absinthe.Relay.Schema.Notation, :modern

  node object :thing do
    field :id, :id    # <---- removing this fixed the error
    field :name, :string
    # rest of fields
  end
end

I believe the node macro automatically adds the id field ๐Ÿค”

Was this page helpful?
0 / 5 - 0 ratings