You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cevado 74b6036991 Merge pull request 'Fix typo on rebar.config' (#12) from msramos/boto:fix-typo-on-rebar-config into main 3 months ago
examples Add livebook example in elixir. 3 months ago
src Update doc 3 months ago
.gitignore Initial commit 5 months ago
CHANGELOG.md Update changelog release date 3 months ago
CODE_OF_CONDUCT.md Update readme 4 months ago
LICENSE Fix some config files 5 months ago
README.md Update doc 3 months ago
rebar.config Fix typo on rebar.config 3 months ago
rebar.lock Initial commit 5 months ago

README.md

Boto

Boto is an attempt to provide features similar to what Pathom provides to Clojure/Clojurescript.

The core concept behind Boto is that you won't have to think of entities anymore, you only need to care about the data that you already have and the data that you need. Boto will take care of trying to retrieve all the data that you need, based on resolvers that you registered. Imagine something like graphql but inside your code, that can leverage any source of information that you can reach.

Work in progress

Boto is still in development and there is a lot of work to be done for it to be as useful as it can be. There are some considerations on current behaviour:

  • All resolvers are called in a single process, even for nested attributes.
  • Currently queries are optimistic, what means that if Boto can't resolve everything you queried it gonna return everything it was able to retrieve.
  • For this first experiment, I'm not handling errros for resolvers. So it's just expected for the resolvers to return data correctly.

If those behaviors will be kept or changed, it's open to discussion.

Current Roadmap

  • [i] Document the entire codebase.
  • [i] Full test coverage of complex scenarios and unit tests.
  • [d] Handle resolvers failures, with configurable retries.
  • [d] Failure state when it's not possible to retrieve all data queried.
  • [d] Additional parameter to nested queries.
  • [d] Filters for nested attributes that return N entries.
  • [c] Paralelize resolvers.
  • [c] Cache with TTL for results. [d]: discussion [c]: confirmed [i]: in progress : done

Examples

There are two examples available, both in Elixir and Erlang, showing some scenarios of how to use the library. The simple one is the weather resolver, that can get the current temperature forecast for a given ip, if no ip is provided it gonna use your own ip as resource. The elaborated example is the Hacker News api resolver, that can query the public Hacker News api, including nested resources. There is also a livemd file that you can open with Livebook to explore the library usage.

For reference when reading the docs follows a dummy implementation of boto_resolver behaviour.

Erlang

-module(resolver).
-behaviour(boto_resolver).
-export([resolver_init/0, resolve/2]).

resolver_init() ->
    [{resolver1, [{output, [attribute1, attribute2, attribute3]}]},
     {resolver2, [{input, [attribute1]}, {output, [attribute4, attribute5, attribute6]}]}].

resolve(resolver1, Input) ->
    #{attribute1 => 1, attribute2 => 2, attribute3 => 3};
resolve(resolver2, #{attribute1 := Att1}) ->
    case Att1 of
        1 ->
            #{attribute4 => 4, attribute5 => 5, attribute6 => 6},
        2 ->
            #{attribute4 => 8, attribute5 => 10, attribute6 => 12}
    end.

Elixir

defmodule Resolver do
    @behaviour :boto_resolver
    
    def resolver_init() do
    [
     resolver1: [output: [:attribute1, :attribute2, :attribute3]],
     resolver2: [input: [:attribute1], output: [:attribute4, :attribute5, :attribute6]]
    ]
    end
    
    def resolve(:resolver1, _input) do
        %{attribute1: 1, attribute2: 2, attribute3: 3}
    end
    
    def resolve(:resolver2, %{attribute1: att}) do
        case att do
            1 -> %{attribute4: 4, attribute5: 5, attribute6: 6}
            2 -> %{attribute4: 8, attribute5: 10, attribute6: 12}
        end
    end
end

Contributing

The source of truth for this code is codeberg, provide feedback and join discussion in the issues. A mirror is kept in sourcehut. You're welcomed to interact on both places. Check the code of conduct.