Created
November 11, 2017 12:48
-
-
Save BaylorRae/c74984448d6005a3f6f399b8ca0f15e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Types | |
ProjectType = GraphQL::ObjectType.define do | |
name "Project" | |
description "a project" | |
implements GraphQL::Relay::Node.interface | |
global_id_field :id | |
field :title, !types.String do | |
resolve ->(project, args, ctx) { project.user.email.split('@')[0] + '-' + project.title } | |
end | |
field :user, !UserType | |
connection :tasks, TaskType.connection_type | |
end | |
end |
This file contains hidden or 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
module Types | |
TaskType = GraphQL::ObjectType.define do | |
name "Task" | |
description "a task" | |
implements GraphQL::Relay::Node.interface | |
global_id_field :id | |
field :title, !types.String | |
field :completed, !types.Boolean | |
field :project, !ProjectType | |
end | |
end |
This file contains hidden or 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
query { | |
projects { | |
id | |
title | |
tasks { | |
edges { | |
node { | |
id | |
title | |
completed | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment