FedeMadoery

FedeMadoery

How to add description to graphql fields and operations?

I would like to add docs to my GraphQL types and their fields, so the devs working on the UI side can easily understand the data structure.

I saw that ash-graphql internally uses “Absinthe.Blueprint.Schema.FieldDefinition” but I don’t know how to create my own field description from outside.

In ApolloSandbox the autogenerated page looks like this:

PageOfChannelTag

A page of :channel_tag

Kind of type: [Object]

FIELDS DETAILS
count [Int] Total count on all pages
hasNextPage [Boolean] Whether or not there is a next page
results [ChannelTag] The records contained in the page

Marked As Solved

FedeMadoery

FedeMadoery

Well, I’m sorry about it… I found the answer by searching differently in the Ash repo.

So I am sharing a summary in case someone else faces the same concern:

On the relationships you can do the following

relationships do
     belongs_to :tag, MyApp.Organizations.Tag do
      allow_nil? false
      #This description is mapped directly to the GraphQL Fields
      description "Tag assigned to the channel" 
    end
  end

On the attributes you can do the following

 attributes do
    uuid_primary_key :id do
      #This description is mapped directly to the GraphQL Fields
      description "Primary ID"
    end
  end

The one that took me the most to figure out hehe

calculations do
    calculate :channel_id_test, :uuid do
      #This description is mapped directly to the GraphQL Fields
      description "Channel ID where the tag is assigned to"

      calculation fn record, %{api: api} ->
        api.load!(record, :channel).id
      end
    end
  end

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement