View Source CoseDellaVitaEx.Helpers.MacroHelpers (CoseDellaVitaEx v0.2.0)
Macro helpers for Absinthe.
Link to this section Summary
Functions
Add boilerplate for a mutation payload.
Add boilerplate for pagination (limit
and offset
fields).
Link to this section Functions
Link to this macro
add_mutation_payload(name, error_types, custom_fields \\ nil)
View Source (macro)Add boilerplate for a mutation payload.
Example
add_mutation_payload(:create_user, [:generic_error, :not_found_error])
This generates the following:
- A
create_user_error_types
function, to get a list of possible errors - A
create_user_error
GraphQL union type, representing all possible errors - A
create_user_payload
GraphQL object, containing boilerplate fields for mutations
Additional fields can be added to the payload like so:
add_mutation_payload(:create_user, [:generic_error, :not_found_error]) do
field :some_other_field, :string
end
Add boilerplate for pagination (limit
and offset
fields).
Types can be overriden:
add_pagination_fields(limit_type: :small_integer)