Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introspecting complex default values raises Protocol.UndefinedError #490

Closed
mydearxym opened this issue Jan 18, 2018 · 4 comments · Fixed by #537
Closed

Introspecting complex default values raises Protocol.UndefinedError #490

mydearxym opened this issue Jan 18, 2018 · 4 comments · Fixed by #537

Comments

@mydearxym
Copy link

mydearxym commented Jan 18, 2018

hi guys ~

i am using default_value in input_object , it worked , but there some error in console when i refresh the schema in graphql-playground ..

input_object :article_filter do
    field(:first, :integer, default_value: 20)
    field(:order, :sort_order, default_value: :desc)
    field(:tag, :string, default_value: :all)
  end

field :posts, non_null(list_of(non_null(:post))) do
    arg(:filter, :article_filter, default_value: %{first: 20})
    resolve(&Resolvers.CMS.posts/3)
end

image

image

error detail:

Request: POST /graphiql
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for %{first: 20}. This protocol is implemented for: Atom, BitString, Date, DateTime, Decimal, Ecto.Date, Ecto.DateTime, Ecto.Time, Float, Integer, List, NaiveDateTime, Postgrex.Copy, Postgrex.Query, Postgrex.Stream, Time, URI, Version, Version.Requirement
@mydearxym mydearxym changed the title default_value not supported in input_object ? default_value in input_object throw a Error message Jan 19, 2018
@bruce
Copy link
Contributor

bruce commented Jan 19, 2018

This does appear to be a bug, based on my reading of http://facebook.github.io/graphql/October2016/#sec-The-__InputValue-Type

"defaultValue may return a String encoding (using the GraphQL language) of the default value used by this input value in the condition a value is not provided at runtime. If this input value has no default value, returns null."

I'd take a wild bet we haven't seen this before because this is the first complex default value someone's tried to introspect.

@bruce bruce changed the title default_value in input_object throw a Error message Introspecting complex default values raises Protocol.UndefinedError Jan 19, 2018
@binaryseed
Copy link
Contributor

We also ran into this recently...

@richeterre
Copy link

@bruce @binaryseed Has this fix been released yet? I'm running v1.4.16 and see a similar error when providing an empty map as the default value for my field arg:

field :performances, list_of(non_null(:performance)) do
  arg :filter, :performance_filter, default_value: %{}
  ...
end

input_object :performance_filter do
  field :stage_date, :date
  field :stage_id, :id
end

Reloading the schema in GraphQL Playground causes the following console output:

** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for %{}. This protocol is implemented for: Postgrex.Copy, Postgrex.Query, Decimal, Float, DateTime, Time, List, Version.Requirement, Atom, Integer, Version, Date, BitString, NaiveDateTime, URI

Am I missing anything here? Any pointers are greatly appreciated 🙂

@benwilson512
Copy link
Contributor

@richeterre this fix is in the 1.5 series of releases, we may not have back ported it to 1.4

richeterre added a commit to richeterre/jumubase that referenced this issue Jun 26, 2019
A fix will be included in Absinthe v1.5, so after upgrading we can again set an empty map as the default value for performance filters. See issue: absinthe-graphql/absinthe#490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants