-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for subscription type #1096
Comments
What do you think about this API? const graffle = Graffle
.create()
.transport({
url: '',
})
.use(Subscription())
const ProjectSubscription = gql(`
subscription ProjectSubscription {
project {
name
slug
}
}
`)
const unsubscribe = graffle
// or .subsription(ProjectSubscription, {})
.gql(ProjectSubscription, {})
.subscribe((data) => {
/**
* incoming data
* {
* project: {
* name: string
* slug: string
* }
* }
*/
console.log(data)
})
|
const graffle = Graffle.create()
const subscription = await graffle
.gql`
subscription {
project {
name
slug
}
}
`
.subscribe()
console.log(subscription.response)
let i=0
await for (event of subscription) {
i++
console.log(event)
/**
* {
* project: {
* name: string
* slug: string
* }
* }
*/
if (i===4) break
}
await subscription.cancel() Document Builder: const subscription = await graffle.subscription.project({
name,
slug,
}) Key points:
Reasons we might want
wdyt? |
i think i like it! also, if you use |
fwiw We can also make it work cross transport, e.g. |
Perceived Problem
Ideas / Proposed Solution(s)
The text was updated successfully, but these errors were encountered: