Skip to content

Instantly share code, notes, and snippets.

query {
hello(name: "Alice")
}
type Query {
hello(name: String): String
}
// generated methods
//
// Pros:
// - simple to get started
// - minimal/concise syntax
//
// Cons:
// - no response types
// - no arguments on sublevels
// - codegen step needed for typesafe variant
mutation {
deletePost(id: "__POST_ID__") {
id
}
}
{
"post": {
"previousValues": {
"id": "...",
"title": "...",
}
}
}
subscription {
post {
previousValues {
id
title
}
}
}
const resolvers = {
Query: {
// ... like before
},
Mutation: {
// ... like before
},
Subscription: {
publications: {
// ... like before
type Subscription {
publications: PostSubscriptionPayload
postDeleted: Post
}
mutation {
writePost(title: "GraphQL subscriptions are awesome") {
id
}
}
subscription {
publications {
node {
id
title
}
}
}