This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Web.Schema.Types do | |
use Absinthe.Schema.Notation | |
use Absinthe.Relay.Schema.Notation | |
node interface do | |
resolve_type fn | |
# Guess type from struct name: | |
# Example: MyApp.Model.Foo -> :foo | |
%{__struct__: str}, _ -> | |
str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
cwd { | |
basename | |
... on Directory { | |
entries { | |
basename | |
... on Directory { | |
basename | |
stat { | |
size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
items(first: 5) { | |
count | |
edges { | |
node { | |
name | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Schema do | |
use Absinthe.Schema | |
object :user do | |
# Define your user type | |
end | |
query do | |
field :viewer, :user do | |
resolve &resolve_viewer/3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object :user do | |
field :id, :id | |
field :email, :string | |
field :password, :string # if you really want to make it available | |
field :enabled, :boolean | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Color do | |
@moduledoc """ | |
Just an example source of the values | |
""" | |
def list do | |
~w(red green blue)a | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/Login/Login.js | |
class Login extends Component { | |
// ... | |
handleSubmit(evt) { | |
evt.preventDefault(); | |
this.props.mutate(this.state) | |
.then(({ data }) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExampleSchema do | |
use Absinthe.Schema | |
# rest of schema | |
object :message do | |
field :date, :datetime do | |
resolve source_field(:inserted_at) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule TestSchema do | |
use Absinthe.Schema | |
query do | |
field :hello, :float do | |
resolve fn _, _, _ -> {:ok, 1.3} end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Schema do | |
use Absinthe.Schema | |
mutation do | |
field :create_user, :user do | |
arg :input, :user_creation | |
resolve fn | |
_, %{input: input}, _ -> | |
# create from `input`, assign `user` | |
{:ok, user} |