Skip to content

Instantly share code, notes, and snippets.

@MuddyBootsCode
Last active September 23, 2020 15:07
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 MuddyBootsCode/b8b30f8bff384966e6b95b34a8065139 to your computer and use it in GitHub Desktop.
Save MuddyBootsCode/b8b30f8bff384966e6b95b34a8065139 to your computer and use it in GitHub Desktop.
directive @subscribe on FIELD_DEFINITION
directive @publish(to: String!) on FIELD_DEFINITION | OBJECT
type User @isAuthenticated {
id: ID!
firstName: String!
lastName: String!
}
// The subscription created for the auto generated
type Task @publish(to: "autotaskAdded"){
id: ID!
content: String!
column: Column @relation(name: "BELONGS_TO", direction: "OUT")
columnName: String @cypher (
statement: "MATCH (this)-[:BELONGS_TO]->(c:Column) return c.title"
)
}
type Column {
id: ID!
title: String!
tasks: [Task] @relation(name: "BELONGS_TO", direction: "IN")
table: Table @relation(name: "BELONGS_TO", direction: "OUT")
taskIds: [ID]
}
type Table {
id: ID!
title: String!
columns: [Column] @relation(name: "BELONGS_TO", direction: "IN")
columnOrder: [ID]
}
type Subscription {
taskAdded: Task @subscribe
autoTaskAdded: Task @subscribe
}
type Mutation {
addTask(taskContent: String!, columnId: ID!): Task @publish(to: "taskAdded")
@cypher (
statement: "CREATE (t:Task { id: randomUUID(), content: $taskContent }) with t MATCH(c:Column {id: $columnId}) CREATE(c)<-[:BELONGS_TO]-(t) set c.taskIds = c.taskIds + t.id return t"
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment