chu
I don’t know how to structure this question well so here it goes:
I have this:
[%{"first_name" => "John", "id" => "651029dc-636d-4e54-a03d-d80097c7567e", "last_name" => "Doe", "user_id" => "23232323"}, %{"first_name" => "John", "id" => "41188ffc-4304-4b01-9c45-7565aa8a4aab", "last_name" => "Doe", "user_id" => "23232323"}, %{"first_name" => "John", "id" => "277dd91f-c8e6-4104-b7b0-fecedf933b54", "last_name" => "Doe", "user_id" => "23232323"}]
I need to retrieve
%{"first_name" => "John", "id" => "651029dc-636d-4e54-a03d-d80097c7567e", "last_name" => "Doe", "user_id" => "23232323"}, %{"first_name" => "John", "id" => "41188ffc-4304-4b01-9c45-7565aa8a4aab", "last_name" => "Doe", "user_id" => "23232323"}, %{"first_name" => "John", "id" => "277dd91f-c8e6-4104-b7b0-fecedf933b54", "last_name" => "Doe", "user_id" => "23232323"}
Because of how I rendering these results on my GraphQL endpoint. How can I extract the data without the ?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
uranther
I am a little confused by the question, but maybe you want to use
Enum.each/2or some of the other Enum functions. I hope that helps!NobbZ
The first part of your question shows a List of Maps, the second example you show, is not valid Elixir… At least not for itself…
So please try to elaborate further what exactly you want to achieve, where your data comes from and where you want to send it into.
chu
My data is coming from a RethinkDB store, let me investigate further because I am using a resolver I got from a git repo to send that data into my GraphQL resolvers. If I have my data in the second format
it works but not when it’s a list of Maps hence my frustration.
I am using rethinkdb-elixir and I the absinthe-graphql plugin. If I query my database using
|> get(args.user_id)it returns data in %{} format but when I use|> filter(%{user_id: args.user_id})it returns [%{}] and I get an error sayingexpected a map, got: [%{I am hitting a snag within this code:
Generally I am following this repo
The source part of the code above is:
NobbZ
Since you not really did go into my questions, I can’t really help you.
Can you point us to the exact libraries you are using, can you tell us how you get the data and how you emit the data to the receiver?
Is the list you get from a message sent by another node or was it returned by a simple function call?
Do you need to send the Stuff Map by Map to your GraphQL-thing? Do you need to do it by a function call against a library or do you send a message?
If you can’t answer these questions using words, set up a minimum mix-project which shows your problem in a simplified manner.
NobbZ
It had been better if you had answered instead of editing, but OK, lets do it this way.
As far as I can tell you get a list of maps from somwhere and need to send only a single map per call so somewhere else, so a simple proxy from list to many calls with single maps, something along the following might help:
PS: The link you gave, seems to be dead…
chu
The correct link is GitHub - AdamBrodzinski/awesome-stack at phoenix-1.2-new-graphql · GitHub
peerreynders
I think you are facing an issue with your design - have a look at query.ex -
getqueries usehandle_get_response(is_map) in the pipeline while thefilterqueries usehandle_get_many_response(is_list) - i.e. by designgetqueries return at most one result as a single map whilefilterqueries return zero-to-many results (each in their own map) in a list.Now look at user_query.ex - it uses
getand you can’t just dropfilterin its place as that would (in this case) breakconvert_to_string_map:In essence the
filterquery needs a pipeline afterrunthat can process a list of maps. Now you could wrap the result of agetquery inside a list so that it can be processed by the pipeline that was designed for results from afilterquery but I suspect that would create problems with the GraphQL response.chu
Thanks for that response, have a look at the phoenix-1.2-new-graphql branch of the same repo. That is the one I am using. I also feel that I might be missing something fundamental on how to resolve Lists to Maps in each query in GraphQL helpers to ensure compatibility.
If you look at that branch he is using this block of code to handle the ‘transformations’
This is where it’s hitting a snag.
chu
Adam Brodzinski, the author of that example stack was kind enough to direct me to the right place. This is his response:
So basically using
type: list_of(:user)resolved the issue I was having.peerreynders
Essentially you had an error in your schema:
web/schema.ex
The missing
list_ofresulted in thedefault_resolvebeing presented with data that it shouldn’t have to handle.This demonstrates that one should not immediately assume that the fault lies where it manifests itself - the problem is often further up stream.