Packages
graphqexl
0.1.0-alpha-rc.2
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.ex
alias Graphqexl.Schema.{
Dsl,
Enum,
Interface,
Mutation,
Query,
Subscription,
Type,
Union,
}
defmodule Graphqexl.Schema do
defstruct(
enums: [],
interfaces: [],
mutations: [],
queries: [],
str: "",
subscriptions: [],
types: [],
unions: []
)
@type gql :: String.t()
@type t :: %Graphqexl.Schema{
enums: list(Enum.t),
interfaces: list(Interface.t),
mutations: list(Mutation.t),
queries: list(Queries.t),
str: gql,
subscriptions: list(Subscription.t),
types: list(Type.t),
unions: list(Union.t),
}
def gql(str) do
%Graphqexl.Schema{str: str |> Dsl.preprocess}
end
@spec register(
GraphqexlSchema.t,
Enum.t |
Interface.t |
Mutation.t |
Query.t |
Subscription.t |
Type.t |
Union.t
) :: Graphqexl.Schema.t
def register(schema, %Enum{} = enum) do
schema |> register(:enums, enum)
end
def register(schema, %Interface{} = interface) do
schema |> register(:interfacess, interface)
end
def register(schema, %Mutation{} = mutation) do
schema |> register(:mutations, mutation)
end
def register(schema, %Query{} = query) do
schema |> register(:queries, query)
end
def register(schema, %Subscription{} = subscription) do
schema |> register(:subscriptions, subscription)
end
def register(schema, %Type{} = type) do
schema |> register(:types, type)
end
def register(schema, %Union{} = union) do
schema |> register(:unions, union)
end
defp register(schema, key, value) do
schema |> Map.update(key, value, &prepend_list/2)
end
defp prepend_list(list, value) do
list |> List.insert_at(0, value)
end
end