Packages
graphqexl
0.1.0-alpha-rc.20
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/type.ex
alias Graphqexl.Schema.{
Interface,
Ref
}
defmodule Graphqexl.Schema.Type do
@moduledoc """
GraphQL type
"""
defstruct(
deprecated: false,
deprecation_reason: "",
description: "",
fields: [],
implements: nil,
name: ""
)
@type t ::
%Graphqexl.Schema.Type{
deprecated: boolean(),
deprecation_reason: String.t(),
description: String.t(),
fields: Map.t(),
implements: Interface.t() | nil,
name: String.t()
}
@doc """
Lists the fields available on the given `t:Graphqexl.Schema.Type.t/0`.
Returns: `[t:Graphqexl.Schema.Field.t/0]`
"""
@doc since: "0.1.0"
@spec fields(Graphqexl.Schema.Type.t):: list(Graphqexl.Schema.Field.t)
def fields(type) do
implemented_fields = if is_nil(type.implements) do
[]
else
type.implements |> Ref.fields
end
type.fields |> Map.keys |> Enum.concat(implemented_fields)
end
@doc """
Checks whether the given field is a custom scalar type.
Returns: `t:boolean`
"""
@doc since: "0.1.0"
@spec is_custom_scalar?(Graphqexl.Schema.Type.t, atom):: boolean
def is_custom_scalar?(type, field) do
[:String, :Integer, :Float, :Boolean, :Id] |> type.implements?(field)
end
end