mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Document subscription plugins
This commit is contained in:
+32
@@ -92,6 +92,10 @@ type RootMutation {
|
|||||||
type RootQuery {
|
type RootQuery {
|
||||||
people: [Person!]
|
people: [Person!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Subscription {
|
||||||
|
leader: Person
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Thanks to [gql-merge](https://www.npmjs.com/package/gql-merge) the contents of
|
Thanks to [gql-merge](https://www.npmjs.com/package/gql-merge) the contents of
|
||||||
@@ -206,6 +210,23 @@ If your post function accepts four parameters, then it can modify the field
|
|||||||
result. It is *required* that the function resolves a promise (or returns) with
|
result. It is *required* that the function resolves a promise (or returns) with
|
||||||
the modified value or simply the original if you didn't modify it.
|
the modified value or simply the original if you didn't modify it.
|
||||||
|
|
||||||
|
#### Field: `setupFunctions`
|
||||||
|
|
||||||
|
```js
|
||||||
|
setupFunctions: {
|
||||||
|
leader: (options, args) => ({
|
||||||
|
leader: {
|
||||||
|
filter: (person) => person.place === 1
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Setup functions allow you to create filters that control which pubsub.publish() events
|
||||||
|
send data to the client. If the type in question contains args, clients may subscribe using those arguments to further filter their subscription.
|
||||||
|
|
||||||
|
For more information, see the [Apollo Docs](https://github.com/apollographql/graphql-subscriptions).
|
||||||
|
|
||||||
#### Field: `router`
|
#### Field: `router`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -322,6 +343,10 @@ module.exports = {
|
|||||||
type RootQuery {
|
type RootQuery {
|
||||||
people: [Person!]
|
people: [Person!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Subscription {
|
||||||
|
leader: Person
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
context: {
|
context: {
|
||||||
Slack: () => ({
|
Slack: () => ({
|
||||||
@@ -377,6 +402,13 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setupFunctions: {
|
||||||
|
leader: (options, args) => ({
|
||||||
|
leader: {
|
||||||
|
filter: (person) => person.place === 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user