Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscription type throws build error #1323

Open
paniavula opened this issue Aug 5, 2020 · 0 comments
Open

subscription type throws build error #1323

paniavula opened this issue Aug 5, 2020 · 0 comments
Labels
type/bug Something is not working the way it should

Comments

@paniavula
Copy link

The latest 0.26.1 throws back errors on build when subscriptionType is used. Sample subscription snippet is below.

import { schema } from 'nexus'
import { PubSub } from 'graphql-subscriptions'

const pubsub = new PubSub()

schema.subscriptionType({
  definition(t) {
    t.field('notif', {
      type: 'Json',
      subscribe(root, args, ctx, info) {
        return pubsub.asyncIterator('notification')
      },
      resolve(event, args, ctx, info) {
        return { a: 10 }
      },
    })
  },
})

Repro

  1. npx nexus@next
  2. Add above snippet to any of your code file
  3. npm run build -- throws the below error
 758 ● nexus:build get used plugins
● nexus:plugin:nexusPluginPrisma Running generators
● nexus:build starting reflection
● nexus:build building typescript program
● nexus:build compiling a production build
node_modules/@nexus/schema/dist/definitions/subscriptionType.d.ts:31:9 - error TS2416: Property 'list' in type 'SubscriptionDefinitionBlock' is not assignable to the same property in base type 'ObjectDefinitionBlock<"Subscription">'.
  Type 'SubscriptionDefinitionBlock' is not assignable to type 'OutputDefinitionBlock<"Subscription">'.
    Types of property 'field' are incompatible.
      Type '<FieldName extends string>(name: FieldName, fieldConfig: SubscribeFieldConfig<"Subscription", FieldName, any>) => void' is not assignable to type '<FieldName extends string>(name: FieldName, fieldConfig: FieldOutConfig<"Subscription", FieldName>) => void'.
        Types of parameters 'fieldConfig' and 'fieldConfig' are incompatible.
          Type 'FieldOutConfig<"Subscription", FieldName>' is not assignable to type 'SubscribeFieldConfig<"Subscription", FieldName, any>'.
            Type 'NexusOutputFieldConfig<"Subscription", FieldName> | (NexusOutputFieldConfig<"Subscription", FieldName> & { ...; })' is not assignable to type 'SubscribeFieldConfig<"Subscription", FieldName, any>'.
              Property 'subscribe' is missing in type 'NexusOutputFieldConfig<"Subscription", FieldName>' but required in type 'SubscribeFieldConfig<"Subscription", FieldName, any>'.

31     get list(): SubscriptionDefinitionBlock;
           ~~~~

  node_modules/@nexus/schema/dist/definitions/subscriptionType.d.ts:23:5
    23     subscribe(root: object, args: ArgsValue<TypeName, FieldName>, ctx: GetGen<'context'>, info: GraphQLResolveInfo): MaybePromise<AsyncIterator<T>> | MaybePromiseDeep<AsyncIterator<T>>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'subscribe' is declared here.
@paniavula paniavula added the type/bug Something is not working the way it should label Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working the way it should
Projects
None yet
Development

No branches or pull requests

1 participant