Read-only graphql/json api with elixir and/or phoenix

hello, i’m looking to build a simple read-only json/graphql api with elixir. so i don’t need authentication.

any guides on how to do this?


Welcome to the forum.

Can you share some code first and also explain in more detail what you need(requirements)?


Graphql api for elixir devs (only queries)

my query is pretty clear, i think: i wish to build a graphql and/or json api with elixir. most tutorials/guides assume GET/POST REST behaviour. but i don’t need POST behaviour, i don;t need to update the api, only to query it. so i don’t need authentication.

is there a simple guide to making such an api (with or without phoenix)?

In phoenix / for a json API just don’t implement anything, which is not needed for reading.

resources "/api/resources", ResourceController, only: [:index, :show]
# or
get "/api/resources", ResourceController, :index
get "/api/resources/:id", ResourceController, :show
1 Like

As mentionned by @LostKobrakai, making a json is quite direct…

But if You want to do GraphQL, You will have to use Absinthe.

Making it read only is just much easier, because You just defines queries, no mutations, no subscriptions.

If your source is db, You will have to define ecto queries. Eventually use DataMapper…

Any tutos on graphql starts by implementing queries.

1 Like

So you will have the following stack using graphql

Also a big advantage with Graphql is the graphql playground, where you can test your api.

Apollo Client for front-end(depends what client you will have angular react vue)

my front-end will be elm…


  • which json tutorial/guide do you recommend?
  • which graphql tutorial/guide do you recommend?

If you are familiar with elm then try this

If not you will have to learn phoenix first then dive in graphql

Other paths can be found using google searching graphql tutorial

maybe i should be clearer:

which phoenix + json tutorial/guide do you recommend?
which phoenix + graphql tutorial/guide do you recommend?

phoenix+ json problems complicated

phoenix+graphql this

phoenix + json is complicated? i thought it was the easiest thing to do?

Phoenix + JSON is simple, and you do not need any special dependency: support for JSON comes out of the box from Phoenix. Any Phoenix tutorial would work well, but a web search for “Phoenix JSON API” shows me these:

For GraphQL, look into Absinthe.

Note that GraphQL uses POST even if you have a read-only API. That’s because, differently from REST, it uses one single endpoint, and relies on the query language to figure out what to fetch or write. As the query might not fit into the GET parameters, POST is used.

1 Like

At first json api may seem a good option, but once you start versioning you will have a lot to maintain especially if you are going to have users that will use separate versions of your api.


  • 10 users on /api/v1
  • 15 users on /api/v2

Graphql is version less so no: version 1 or two or three, much nicer.