This repository was archived by the owner on Dec 8, 2021. It is now read-only.
  
  
  - 
                Notifications
    
You must be signed in to change notification settings  - Fork 54
 
Subscription types are incorrect #479
Copy link
Copy link
Open
Description
Given a schema:
type Subscription {
  status(acdEngineId: Int!): JobStatus!
}
type JobStatus {
  jobStatus: String!
}
and types:
export interface JobStatus {
  jobStatus: string;
}
The generated subscription types looks like this:
export interface Type {
    status: {
      subscribe: (
        parent: undefined,
        args: JobStatus,
        ctx: Context,
        info: GraphQLResolveInfo
      ) => AsyncIterator<JobStatus> | Promise<AsyncIterator<JobStatus>>;
      ...
    };
  }
Which implies that we need an AsyncIterator that yields objects of type JobStatus, that is to say:
{
   jobStatus: 'something'
}But when I use a custom written AsyncIterator to achieve this, I get errors saying jobStatus cannot be null. What I actually need to yield is the whole data payload:
{
   status: {
      jobStatus: 'something'
   }
}Is this a bug or am I doing something wrong?
EDIT:
I feel this is also apparent in graphql-yoga examples, we need to return the entire payload i.e:
https://github.com/prisma/graphql-yoga/tree/master/examples/subscriptions
type Counter {
   count: Int!
   countStr: String
}
type Subscription {
    counter: Counter!
}
pubsub.publish(channel, { counter: { count: count++ } })instead of just
pubsub.publish(channel, { count: count++ })Versions
graphqlgen: 0.6.0-rc9
OS: Windows 10
Metadata
Metadata
Assignees
Labels
No labels