apollographql / apollographql/graphql-subscriptions
Who does the logic to add graphql spec fields on the payload like `__typename`?
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
I am exploring this library and trying to understand more about graphql spec level. When the server calls `publish`, I can see it just pass the payload to subscribers via `EmitEmitter`. But the client side expects a payload which includes a wrapper of the published payload.
For example, if the publisher publishes a payload like:
```
{
topic: "xx", message: ...
}
```
what the subscriber receive should be something like:
```{
data: {
event: {
topic: "xx", message: ..., __typename: ...
...
```
the `data` top level field is from graphql spec, every payload should be under it. The `event` is the operation name from graphql schema. The `__typename` is the type of the schema. I wonder how this logic get added to the response?
Contributor guide
Research direction
Start with the EmitEmitter path mentioned in the issue and trace how published payloads reach the GraphQL subscription response. Then inspect the subscription schema and client-side response handling to identify where data, the operation field, and __typename are introduced. Done means documenting the responsible layer and response flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100