Packages
graphqexl
0.1.0-alpha-rc.25
0.1.0
0.1.0-alpha-rc.docs-test-6
0.1.0-alpha-rc.docs-test-5
0.1.0-alpha-rc.docs-test-4
0.1.0-alpha-rc.docs-test-3
0.1.0-alpha-rc.docs-test-2
0.1.0-alpha-rc.docs-test
0.1.0-alpha-rc.25
0.1.0-alpha-rc.24
0.1.0-alpha-rc.23
0.1.0-alpha-rc.22
0.1.0-alpha-rc.21
0.1.0-alpha-rc.20
0.1.0-alpha-rc.19
0.1.0-alpha-rc.18
0.1.0-alpha-rc.17
0.1.0-alpha-rc.16
0.1.0-alpha-rc.15
0.1.0-alpha-rc.14
0.1.0-alpha-rc.13
0.1.0-alpha-rc.12
0.1.0-alpha-rc.11
0.1.0-alpha-rc.10
0.1.0-alpha-rc.9
0.1.0-alpha-rc.8
0.1.0-alpha-rc.7
0.1.0-alpha-rc.6
0.1.0-alpha-rc.5
0.1.0-alpha-rc.4
0.1.0-alpha-rc.3
0.1.0-alpha-rc.2
0.1.0-alpha-rc.1
0.1.0-alpha.rc-4
0.1.0-alpha.rc.4
Fully-loaded, pure-Elixir GraphQL server implementation with developer tools
Current section
Files
Jump to
Current section
Files
lib/graphqexl/schema/ref.ex
alias Graphqexl.Schema.{
Field,
Interface,
Type,
Union,
}
defmodule Graphqexl.Schema.Ref do
@moduledoc """
Ref struct, representing a connection to another user-defined type
(that may not yet actually be defined in the run-time context)
"""
@moduledoc since: "0.1.0"
defstruct type: %{}
@type component:: Interface.t | Type.t | Union.t
@type t:: %Graphqexl.Schema.Ref{type: atom}
@placeholder %{}
@doc """
Returns a list of the `t:Graphqexl.Schema.Field.t/0`s available on the type resolved to by the
given `t:Graphqexl.Schema.Ref.t/0`.
Returns: `[t:Graphqexl.Schema.Field.t/0]`
"""
@doc since: "0.1.0"
@spec fields(t) :: list(Field.t)
def fields(ref) do
case ref.type do
:Interface -> ref.type |> Interface.fields
:Type -> ref.type |> Type.fields
:Union -> ref.type |> Union.fields
_ -> raise "Unknown ref type! Got: #{ref.type}}"
end
end
@doc """
Resolves the given `t:Graphqexl.Schema.Ref.t/0` into its corresponding
`t:Graphqexl.Schema.Ref.component/0`.
Returns: `t:Graphqexl.Schema.Ref.component/0`
"""
@doc since: "0.1.0"
@spec resolve(t) :: component
# TODO: fully implement
def resolve(ref), do: @placeholder |> Map.get(ref.type)
end