View Source Resourceful.JSONAPI.Include (Resourceful v0.1.2)

Functions for validating includes, primarily for use with JSON:API inclusion of related resources.

Includes are just relationships names on the root type. A song, for instance, could include the album and, depending on the depth settings, could even include the album's artist.

Link to this section Summary

Functions

Validates whether a relationship may be included. A graphed relationship where graph? is true may be included.

Link to this section Functions

Link to this function

validate(type, includes)

View Source
@spec validate(
  %Resourceful.Type{
    cache: term(),
    fields: term(),
    id: term(),
    max_depth: term(),
    max_filters: term(),
    max_sorters: term(),
    meta: term(),
    name: term(),
    registry: term()
  },
  String.t() | [String.t()]
) ::
  [
    {:ok,
     %Resourceful.Type.GraphedField{
       field: term(),
       map_to: term(),
       name: term(),
       parent: term(),
       query_alias: term()
     }}
  ]
  | [Resourceful.Error.t()]

Validates whether a relationship may be included. A graphed relationship where graph? is true may be included.

Link to this function

validate(type, includes, input \\ nil)

View Source