Skip to content

Commit 0030a6e

Browse files
Update subscriptions.md
1 parent f55f205 commit 0030a6e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

content/graphql/subscriptions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Note that subscriptions, by definition, return an object with a single top level
5858

5959
This construct produces the same SDL as the previous code sample, but allows us to decouple the method name from the subscription.
6060

61-
### Publishing
61+
#### Publishing
6262

6363
Now, to publish the event, we use the `PubSub#publish` method. This is often used within a mutation to trigger a client-side update when a part of the object graph has changed. For example:
6464

@@ -85,7 +85,7 @@ type Subscription {
8585

8686
This tells us that the subscription must return an object with a top-level property name of `commentAdded` that has a value which is a `Comment` object. The important point to note is that the shape of the event payload emitted by the `PubSub#publish` method must correspond to the shape of the value expected to return from the subscription. So, in our example above, the `pubSub.publish('commentAdded', {{ '{' }} commentAdded: newComment {{ '}' }})` statement publishes a `commentAdded` event with the appropriately shaped payload. If these shapes don't match, your subscription will fail during the GraphQL validation phase.
8787

88-
### Filtering subscriptions
88+
#### Filtering subscriptions
8989

9090
To filter out specific events, set the `filter` property to a filter function. This function acts similar to the function passed to an array `filter`. It takes two arguments: `payload` containing the event payload (as sent by the event publisher), and `variables` taking any arguments passed in during the subscription request. It returns a boolean determining whether this event should be published to client listeners.
9191

@@ -99,7 +99,7 @@ commentAdded(@Args('title') title: string) {
9999
}
100100
```
101101

102-
### Mutating subscription payloads
102+
#### Mutating subscription payloads
103103

104104
To mutate the published event payload, set the `resolve` property to a function. The function receives the event payload (as sent by the event publisher) and returns the appropriate value.
105105

0 commit comments

Comments
 (0)