Skip to content
This repository was archived by the owner on May 17, 2025. It is now read-only.
This repository was archived by the owner on May 17, 2025. It is now read-only.

Publish doesn't execute resolvers #337

Description

@emmavray

I've implemented the provided example (arc-basic-events), and am noticing an issue where the subscription payload doesn't resolve correctly and is sent to client(s) as null.

The cause seems to be in the publish function, which calls graphql.execute on the provided schema. The rootValue passed to execute() is actually the full publish event including topic, rather than just the payload.

Here's a minimal example:

type Subscription {
     example: String
}

await subscriptionServer.publish({ 
     topic: 'example',
     payload: { example: "Hello world!" },
});

In the above example, publish calls execute with a root value of the entire object provided to publish. As a result, graphql.execute never actually calls the resolver -- this makes sense since there's no data at 'example' to resolve.

Modifying publish to pass event.payload rather than the entire event fixes this issue, and resolves the value as expected.

I'm new to graphql so I may be misunderstanding. Is there a reason the entire event object is passed as rootValue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions