Skip to content

Instantly share code, notes, and snippets.

@BaylorRae
Created November 11, 2017 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaylorRae/c74984448d6005a3f6f399b8ca0f15e6 to your computer and use it in GitHub Desktop.
Save BaylorRae/c74984448d6005a3f6f399b8ca0f15e6 to your computer and use it in GitHub Desktop.
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
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
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