GreenFairy.BuiltIns.Node (GreenFairy v0.3.0)
View SourceBuilt-in Relay Node interface.
This interface provides the standard Relay Global Object Identification pattern with a globally unique ID field.
Usage
Types can implement this interface:
defmodule MyApp.GraphQL.Types.User do
use GreenFairy.Type
import GreenFairy.Relay.Field
type "User", struct: MyApp.User do
implements GreenFairy.BuiltIns.Node
global_id :id # Generates globally unique ID
field :email, :string
end
endWith Custom Node Resolution
For the node(id: ID!) query to work, define a node resolver:
type "User", struct: MyApp.User do
implements GreenFairy.BuiltIns.Node
node_resolver fn id, _ctx ->
MyApp.Accounts.get_user(id)
end
global_id :id
field :email, :string
end
Summary
Functions
Finds the GraphQL type identifier for a given Elixir struct.