annrap1d

annrap1d

** (Protocol.UndefinedError) protocol String.Chars not implemented for {:ok, %App.Accounts.User{

Hi there,

I am getting this error after I update information.

[error] #PID<0.1239.0> running AppWeb.Endpoint (connection #PID<0.1051.0>, stream id 10) terminated
Server: localhost:4000 (http)
Request: POST /graphiql
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for {:ok, %App.Accounts.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "337061ec-4438-4cea-91cc-d20637646026", first_name: "John", first_name_hash: <<2, 212, 40, 245, 74, 85, 161, 208, 10, 223, 126, 116, 1, 39, 94, 145, 6, 188, 74, 220, 191, 129, 168, 2, 36, 81, 31, 5, 106, 112, 20, 38>>, last_name: "Doe", last_name_hash: <<138, 38, 87, 124, 31, 176, 136, 55, 43, 37, 13, 53, 13, 215, 51, 141, 175, 81, 246, 142, 152, 55, 81, 62, 254, 25, 107, 192, 232, 21, 127, 255>>, username: "9h777yf", gender: "Male", dob: ~D[1970-01-01], email: "venkat@example.com", email_hash: <<226, 154, 65, 95, 52, 227, 165, 42, 151, 70, 133, 30, 188, 86, 112, 123, 75, 201, 41, 68, 240, 181, 170, 44, 171, 204, 117, 236, 26, 7, 89, 167>>, password_hash: "$pbkdf2-sha512$160000$bK1/jv6n8/raLMhXIzZfiQ$8iyNTdLKixVUZa3E2QJ30DZlkjOjGRrvwEpBOpXw3VoY6iWEtfmobvr5MIxvqBUuCoVAlplfwhRtj7FFpzUbew", password: nil, password_confirmation: nil, primary_phone: nil, primary_phone_hash: nil, alternate_phone: nil, alternate_phone_hash: nil, access_token: "gj3vchbpvb1p3be06h0w4f5v7ktbheah7kdx0m93ofhcfy2q4tqhenbeizlbd8mr0k1x9jfj4m78bl79uptj5goh1d9uwf2x77hh", email_token: "vvtq4yslc0ya7nz0yahl6cc95i3e2p", profile_completed: true, token: nil, terms: nil, country: "US", location: "27215", location_details: %{country_code: "US", country_name: "United States", latitude: 36.0318, longitude: -79.4889, place_name: "Burlington", postal_code: "27215", state_code: "NC", state_name: "North Carolina"}, current_sign_in_at: ~U[2023-08-04 15:43:38Z], last_sign_in_at: ~U[2023-08-04 15:19:50Z], sign_in_count: 13, current_sign_in_ip: nil, last_sign_in_ip: nil, daily_counter: 7, daily_counter_date: ~U[2023-07-23 05:28:20Z], confirmation_code: nil, inputed_code: nil, confirmed_at: ~U[2023-08-04 15:44:37Z], confirmation_sent_at: nil, conversations: #Ecto.Association.NotLoaded<association :conversations is not loaded>, interests: #Ecto.Association.NotLoaded<association :interests is not loaded>, profile: #Ecto.Association.NotLoaded<association :profile is not loaded>, preference: #Ecto.Association.NotLoaded<association :preference is not loaded>, inserted_at: ~N[2023-07-22 04:07:29], updated_at: ~N[2023-08-04 15:54:06]}} of type Tuple
        (elixir 1.15.2) lib/string/chars.ex:3: String.Chars.impl_for!/1
        (elixir 1.15.2) lib/string/chars.ex:22: String.Chars.to_string/1
        (elixir 1.15.2) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
        (absinthe 1.7.1) lib/absinthe/subscription/local.ex:90: Absinthe.Subscription.Local.do_get_docs/3
        (absinthe 1.7.1) lib/absinthe/subscription/local.ex:26: anonymous fn/4 in Absinthe.Subscription.Local.publish_mutation/3
        (elixir 1.15.2) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
        (absinthe 1.7.1) lib/absinthe/subscription/local.ex:25: Absinthe.Subscription.Local.publish_mutation/3
        (absinthe 1.7.1) lib/absinthe/subscription.ex:117: Absinthe.Subscription.publish/3
        (absinthe 1.7.1) lib/absinthe/subscription.ex:207: Absinthe.Subscription.call/2
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:232: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:187: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/3
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:172: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:143: Absinthe.Phase.Document.Execution.Resolution.resolve_fields/4
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:88: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:67: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
        (absinthe 1.7.1) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
        (absinthe 1.7.1) lib/absinthe/pipeline.ex:405: Absinthe.Pipeline.run_phase/3
        (absinthe_plug 1.5.8) lib/absinthe/plug.ex:536: Absinthe.Plug.run_query/4
        (absinthe_plug 1.5.8) lib/absinthe/plug.ex:290: Absinthe.Plug.call/2
        (phoenix 1.6.16) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2

I am doing the following in my absinthe resolver

def update_user(_, args, %{context: context}) do
  user = context[:current_user]

  case Accounts.update_user(user, args) do
    {:error, changeset} ->
      {:error, ChangesetErrors.extract_error_msg(changeset)}

    {:ok, updated_user} ->
      {:ok, updated_user}
  end

I can’t figure out the issue. I have similar resolvers getting a user struct and they all work fine.

Appreciate help!

Marked As Solved

annrap1d

annrap1d

Genius!.. It was indeed the subscription.

I fixed the subscription and it works.

Thank you!

Also Liked

kip

kip

ex_cldr Core Team

This error message is telling you that there is a call to Kernel.to_string/1 on something that can’t be converted to a string. {:ok, struct} cannot be converted to a string. Hence the error.

PS: Also please use Markdown code fences for your code examples. Use triple backticks like:

```elixir
defmodule Blah do

end
```

al2o3cr

al2o3cr

This stacktrace suggests that you should check how your subscriptions are configured; somehow an {:ok, %Account{}} tuple is ending up where the subscription machinery expects a topic.

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement