Skip to content
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

Custom default resolvers #89

Merged
merged 3 commits into from
Mar 17, 2016
Merged

Custom default resolvers #89

merged 3 commits into from
Mar 17, 2016

Conversation

bruce
Copy link
Contributor

@bruce bruce commented Mar 17, 2016

Resolves #77.

Adds a macro, default_resolve, than can be set in a schema to override the built-in default resolve function.

Eg, to support string [instead of atom] keyed maps:

default_resolve fn
  _, %{source: source, definition: %{name: name}} ->
    case source do
      %{} ->
        {:ok, Map.get(source, name)}
       _ ->
        {:ok, nil}
    end
end

@benwilson512 Would appreciate a sanity and performance pass. I've tried to limit the overhead, but it's likely you'll find some improvements with some benchmarking.

end
|> result(ast_node, field, execution)
%{resolve: _} ->
|> process_raw_result(ast_node, field, execution)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support adding, eg, deprecation notices

bruce added a commit that referenced this pull request Mar 17, 2016
@bruce bruce merged commit b85f2af into master Mar 17, 2016
@bruce bruce deleted the default-resolver branch March 17, 2016 20:08
@bruce bruce removed the Status:WIP label Sep 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support overriding default resolver
2 participants