How to use gRPC protobuf enum in Elixir

I run into the issue at runtime, the usage of enum in protobuf generated code looks not right, Here is the code, but I don’t know how to use it, any idea? :

defmodule HelloPhx.ServiceType do
  @moduledoc false
  use Protobuf, enum: true, syntax: :proto3

  @type t :: integer | :LOGIN | :REFRESH_TOKEN 

  field :LOGIN, 0
  field :REFRESH_TOKEN, 1

Here is the error:

[error] ** (Protobuf.EncodeError) Got error when encoding Hellophx.TokenReply#s_type: ** (ArithmeticError) bad argument in arithmetic expression

I just used like this: HelloPhx.ServiceType.LOGIN :slight_smile:
But not working, any idea?

Have you tried this?

1 Like

Yes, already happy using it long time. I got answer here: