graphql-framework-experiment icon indicating copy to clipboard operation
graphql-framework-experiment copied to clipboard

SubscriptionType when building for production has build errors

Open leungandrew opened this issue 5 years ago • 7 comments

Nexus Report

{
  "node": "v14.5.0",
  "os": {
    "platform": "darwin",
    "release": "18.6.0"
  },
  "nexus": "0.26.0-next.1",
  "plugins": [
    "nexus-plugin-prisma"
  ],
  "otherDependencies": {
    "graphql-subscriptions": "^1.1.0"
  },
  "devDependencies": {
    "prettier": "^2.0.5"
  },
  "hasAppModule": true,
  "packageManager": "yarn",
  "errorsWhileGatheringReport": {
    "gettingLayout": null,
    "gettingPluginManifests": null
  }
}

Description

When using the new schema.subscriptionType API, everything is working as expected when running in dev mode. But upon running a nexus build, there are errors produced.

Error: 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.
node_modules/@nexus/schema/dist/definitions/subscriptionType.d.ts:37:5 - error TS2416: Property 'field' in type 'SubscriptionDefinitionBlock' is not assignable to the same property in base type 'ObjectDefinitionBlock<"Subscription">'.
  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>'.

37     field<FieldName extends string>(name: FieldName, fieldConfig: SubscribeFieldConfig<'Subscription', FieldName>): void;
       ~~~~~

  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.

    at Object.emitTSProgram (/Users/andrew/workspace/my-nexus-app-9164280524622883/node_modules/nexus/src/lib/tsc.ts:102:11)
    at Object.buildNexusApp (/Users/andrew/workspace/my-nexus-app-9164280524622883/node_modules/nexus/src/lib/build/build.ts:97:3)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Build.parse (/Users/andrew/workspace/my-nexus-app-9164280524622883/node_modules/nexus/src/cli/commands/build.ts:35:5)

Repro

Can be reproduced via the following repo: https://github.com/leungandrew/nexus-subscriptions-build-error

leungandrew avatar Jul 10 '20 21:07 leungandrew

Related to #447

leungandrew avatar Jul 10 '20 21:07 leungandrew

Same here, on "nexus": "0.26.0-next.3" on nexus build it fails as it checks the typing. naxus dev works fine with no warning/error

NikolaNikushev avatar Jul 11 '20 10:07 NikolaNikushev

@NikolaNikushev @leungandrew Did you manage to find any workaround in the meantime?

nayaabkhan avatar Aug 21 '20 09:08 nayaabkhan

@nayaabkhan I haven't looked into it yet

NikolaNikushev avatar Aug 21 '20 11:08 NikolaNikushev

No worries!

The only workaround I could manage for the meantime is to patch the file in question with @ts-ignore comments using patch-package. Hope this could help someone who comes here looking like I did.

nayaabkhan avatar Aug 22 '20 06:08 nayaabkhan

"skipLibCheck": true in your tsconfig.json should handle this but a real fix will be better

Mikastark avatar Aug 24 '20 13:08 Mikastark

Same problem with @nexus/schema. See https://github.com/graphql-nexus/schema/issues/480

Mikastark avatar Sep 12 '20 10:09 Mikastark