2020-08-14 09:39:59 +12:00
|
|
|
defmodule AshGraphql.Resource.Query do
|
2020-08-15 02:20:47 +12:00
|
|
|
@moduledoc "Represents a configured query on a resource"
|
2021-04-06 02:36:52 +12:00
|
|
|
defstruct [:name, :action, :type, :identity, :allow_nil?]
|
2020-08-14 09:39:59 +12:00
|
|
|
|
|
|
|
@get_schema [
|
|
|
|
name: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The name to use for the query.",
|
|
|
|
default: :get
|
|
|
|
],
|
|
|
|
action: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The action to use for the query.",
|
|
|
|
required: true
|
2020-11-18 20:14:33 +13:00
|
|
|
],
|
|
|
|
identity: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The identity to use for looking up the user",
|
|
|
|
required: false
|
2021-04-06 02:36:52 +12:00
|
|
|
],
|
|
|
|
allow_nil?: [
|
|
|
|
type: :boolean,
|
|
|
|
default: true,
|
|
|
|
doc: "Whether or not the action can return nil."
|
2020-08-14 09:39:59 +12:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2021-04-04 19:10:50 +12:00
|
|
|
@read_one_schema [
|
|
|
|
name: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The name to use for the query.",
|
|
|
|
default: :read_one
|
|
|
|
],
|
|
|
|
action: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The action to use for the query.",
|
|
|
|
required: true
|
2021-04-06 02:36:52 +12:00
|
|
|
],
|
|
|
|
allow_nil?: [
|
|
|
|
type: :boolean,
|
|
|
|
default: true,
|
|
|
|
doc: "Whether or not the action can return nil."
|
2021-04-04 19:10:50 +12:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2020-08-14 09:39:59 +12:00
|
|
|
@list_schema [
|
|
|
|
name: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The name to use for the query.",
|
|
|
|
default: :list
|
|
|
|
],
|
|
|
|
action: [
|
|
|
|
type: :atom,
|
|
|
|
doc: "The action to use for the query.",
|
|
|
|
required: true
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
def get_schema, do: @get_schema
|
2021-04-04 19:10:50 +12:00
|
|
|
def read_one_schema, do: @read_one_schema
|
2020-08-14 09:39:59 +12:00
|
|
|
def list_schema, do: @list_schema
|
|
|
|
end
|