cevado

cevado

repo: GitHub - fcevado/ecto_api · GitHub
This is one idea that I’ve been experiment with and I’m making it public so there can be some discussion to improve these ideas.
Although the name initially might drive someone to think that it’s only for http api, the way i’m envisioning this is that it can be used with any sort of communication protocol.
Even asynchronous protocols might fit here.

Proposed API

I’m thinking t mimic Ecto.Repo for EctoApi with some restrictions and additions:

  • insert_all and update_all aren’t planned to be available.
  • all might happen, but not soon. I’m still uncertain if it’s better to support a limitted version of Ecto.Query or build a proper DSL for this.
  • get_by from Ecto.Repousually just return a single entry so for the current lack of all I’m adding get_all.
  • I’m currently working on how preload should work.
  • so the available functions are insert, update, delete, get, get_by, get_all.

Example:


defmodule User do
  use Ecto.Schema

  @schema_prefix "http://reqres.in/api"
  schema "/users" do
    field(:email, :string)
    field(:first_name, :string)
    field(:last_name, :string)
    field(:avatar, :string)
  end
end

usage:

#insert
%User{}
|> User.changeset(%{first_name: "John", last_name: "Doe"})
|> EctoApi.insert(resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

#update
{:ok, user} =
  %User{}
  |> User.changeset(%{first_name: "John", last_name: "Doe"})
  |> EctoApi.insert(resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

user
|> User.changeset(%{first_name: "Janet", last_name: "Doe"})
|> EctoApi.update(resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

#delete
{:ok, user} =
  %User{}
  |> User.changeset(%{first_name: "John", last_name: "Doe"})
  |> EctoApi.insert(resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

user
|> EctoApi.delete(resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

#get
User
|> EctoApi.get(6, resolver: EctoApi.Resolvers.Rest, client: EctoApi.Clients.Http, builder: User)

i’d like to get some opinions on what have been done so far and some solutions for the issues that I’m having so far(they’re described in the repo readme). I’d like to keep the discussions over the issues of the repo, but I’ll be checking this thread for sure.

Showing Posts 1 to 1

thojanssens1

thojanssens1

I suggest that you mention the intent of the library more clearly and faster.

When looking at the readme, there’s a lot of text (you first state you have an idea you want to make public, then talk about the API, the issues you had, etc.) while it’s still not clear what the library offers.

I think you should first mention what this library does for you and what it saves you (as I think the goal is to write less code?).

— All posts loaded —

Where Next? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New
kip
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shavin...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews