-
Notifications
You must be signed in to change notification settings - Fork 31
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
ordered result example #1
base: master
Are you sure you want to change the base?
Conversation
end | ||
|
||
defp field_data(fields, errors, acc \\ []) | ||
defp field_data([], errors, acc), do: {{:lists.reverse(acc)}, errors} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line here in the normal result phase is:
defp field_data([], errors, acc), do: {Map.new(acc), errors}
This is the only line in the entire file that is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main challenge here is that for large results this function gets called a LOT, and so I want to avoid dynamic lookup. One idea is to use macros:
defmodule BlogWeb.OrdGraphQLResult do
use Absinthe.ResultPhase
def to_object_result(acc) do
{:lists.reverse(acc)}
# or you could do `OrdMap.new(:lists.reverse(acc))`
end
end
pipeline_opts = Keyword.put(pipeline_opts, :result_phase, BlogWeb.OrdGraphQLResult) | ||
config.schema_mod | ||
|> Absinthe.Pipeline.for_document(pipeline_opts) | ||
|> Absinthe.Pipeline.replace(Absinthe.Phase.Document.Result, BlogWeb.OrdGraphQLResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration here is just slightly more complicated than we want.
Hey @benwilson512, I spent today's afternoon and evening trying to install this project's dependencies and run a server, but I wasn't lucky. I encountered many platform specific (Windows) and maybe general problems, e.g. with:
Well, I've managed to compile Elixir 1.6.0-dev from source code - it solved some issues and I've updated this guide: https://github.com/elixir-lang/elixir/wiki/Windows. It's not possible for me to switch to another platform now, so I have to wait for official OTP 21 release and then I'll try it again. Sorry for that and thanks for your time and this PR. |
Hey! Sorry about the difficulties, I'll get a PR up that shows the main point I'm going for without the challenging libraries you have mentioned. |
Should go up sometime tomorrow. |
Hey! Success! I've managed to run this with Nanobox and Docker.
and add flag to
I think a guide about running absinthe_tutorial with Nanobox will be useful. And a guide with Nanobox and Elm frontend for absinthe_tutorial as well. |
prepared for nanobox, graphiql ordered
Some things to note about this:
OrdMap
or:orddict
or whatever it is you end up using won't be as ergonomic to work with in Elixir itself as a map, so this preserves the normalAbsinthe.run
behaviour.