ash_graphql v0.10.0 AshGraphql.Resource View Source

This Ash resource extension adds configuration for exposing a resource in a graphql.

Table of Contents

  • graphql
    • queries
      • get
      • list
    • mutations
      • create
      • update
      • destroy

graphql

Configuration for a given resource in graphql

Examples:

graphql do
  type :post

  queries do
    get :get_post, :default
    list :list_posts, :default
  end

  mutations do
    create :create_post, :default
    update :update_post, :default
    destroy :destroy_post, :default
  end
end

  • :type - Required. The type to use for this entity in the graphql schema

  • :primary_key_delimiter - If a composite primary key exists, this must be set to determine the id field value

queries

Queries (read actions) to expose for the resource.

Examples:

queries do
  get :get_post, :default
  list :list_posts, :default
end

get

A query to fetch a record by primary key

Introspection Target:

AshGraphql.Resource.Query

Examples:

get :get_post, :default
  • :name - The name to use for the query. The default value is :get.

  • :action - Required. The action to use for the query.

  • :identity - false The identity to use for looking up the user

list

A query to fetch a list of records

Introspection Target:

AshGraphql.Resource.Query

Examples:

list :list_posts, :default
  • :name - The name to use for the query. The default value is :list.

  • :action - Required. The action to use for the query.

mutations

Mutations (create/update/destroy actions) to expose for the resource.

Examples:

mutations do
  create :create_post, :default
  update :update_post, :default
  destroy :destroy_post, :default
end

create

A mutation to create a record

Introspection Target:

AshGraphql.Resource.Mutation

Examples:

create :create_post, :default
  • :name - The name to use for the mutation. The default value is :get.

  • :action - Required. The action to use for the mutation.

update

A mutation to update a record

Introspection Target:

AshGraphql.Resource.Mutation

Examples:

update :update_post, :default
  • :name - The name to use for the mutation. The default value is :get.

  • :action - Required. The action to use for the mutation.

  • :identity - The identity to use to fetch the record to be updated.

destroy

A mutation to destroy a record

Introspection Target:

AshGraphql.Resource.Mutation

Examples:

destroy :destroy_post, :default
  • :name - The name to use for the mutation. The default value is :get.

  • :action - Required. The action to use for the mutation.

  • :identity - The identity to use to fetch the record to be destroyed.

Link to this section Summary

Link to this section Functions

Link to this function

decode_primary_key(resource, value)

View Source
Link to this function

encode_primary_key(record)

View Source
Link to this function

primary_key_delimiter(resource)

View Source
Link to this function

type_definition(resource, api, schema)

View Source