DEV Community

Piccione, Marcia
Piccione, Marcia

Posted on • Updated on

goField forceResolver does not quite work as desired for subscriptions

Goal - create organized subscriptions in the graph so it's easier for users to navigate:

extend type Subscription {
cameraSubscriptions: CameraSubscriptions!
}

extend type CameraSubscriptions {
cameraEvent(accountId: String!, deviceId: String!): CameraEvent @goField(forceResolver: true)
}

Generated Code:

func (r *cameraSubscriptionsResolver) CameraEvent(ctx context.Context, obj *model.CameraSubscriptions, accountID string, deviceID string) (*model.CameraEvent, error) {
panic(fmt.Errorf("not implemented: CameraEvent - cameraEvent"))
}

func (r *subscriptionResolver) CameraSubscriptions(ctx context.Context) (<-chan *model.CameraSubscriptions, error) {
panic(fmt.Errorf("not implemented: CameraSubscriptions - cameraSubscriptions"))
}

Expected:

The chan would be applied to the lowest level subscription resolver (CameraEvent) not CameraSubscriptions.

Is there a way to do this or do subscriptions all have to be at the top level of the graph?

Top comments (1)

Collapse
 
mpicci200_comcast profile image
Piccione, Marcia

I was going to delete this but I'll leave it here since I have seen others with the same question. This might actually work as expected as long as the top level can return any object in the channel. I'll test it out.