Ash Query filter function
For background information I have binary field in my datalayer called token when I call this the following function:
but I keep running into the same error highlighted below after inspection.
token exists on resource user , I don't know what the problem is ?
11 Replies
follow up if try and pull_out the token then pin it in my query like below:
the error changes to
(Postgrex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0x97
👋
So you can do
Ash.Query.fitler(query, token == ^user.token)
, don't necessarily need to pull it out to pin it
What data type is your token?Hey @Zach Daniel. I'm working with @edwinofdawn on this. I think we have it figured it out.
The
token
column was a binary type. I kept on running into problems with the binary type, so I changed it to a string
type, and encoded the input value to base64 before writing it to the DB.
While I was still trying to get it to work as a binary
type, I was getting this error:
I thought maybe I need to make the attribute private? true
. That didn't make any difference.
But now thinking about this further, maybe writable? false
would have eliminated that error?private? true
should have done itStrange
🤔 if you can get that error again can you show me a stacktrace/any other context for it?
okay, gotcha
So that looks like its the arguments to a read action
So do you have a "get by token" read action?
That would be another place to change from binary -> string
(and in fact, you probably want to accept a string there anyway since you generally can't get binaries over gql)
Even if the token is a binary in the db
Yeah, there is a
read :get_by_confirmation_token
, but it wasn't being used in my test.Yeah, but the graphql schema gets built fully at compile time
I think I'll leave the column as a string, and base64 encode the value. That's working well, and we won't need to write any conversion logic on read that way.