nexus icon indicating copy to clipboard operation
nexus copied to clipboard

Suport Prisma 4.0.0, Error running version nexus: 1.3.0 Error: NEXUS__UNKNOWN__TYPE was already defined and imported as a type

Open reaink opened this issue 2 years ago • 17 comments

running nexus v1.3.0, prisma v4.0.0 Error: Error: NEXUS__UNKNOWN__TYPE was already defined and imported as a type, check the docs for extending types

reaink avatar Jul 17 '22 16:07 reaink

Hey @reaink , can I please ask what's your current prisma version?

recklyss avatar Jul 26 '22 15:07 recklyss

current version

    "prisma": "3.14.0",
    "nexus": "1.3.0",

update to prisma v4.x throw error NEXUS__UNKNOWN__TYPE

reaink avatar Jul 27 '22 01:07 reaink

I'm having the same error. Downgrading to v3.15.2 didn't fix it. Its still working on a previous project with this prisma version tho. Might be related to something else? It doesn't even generate the outputs for typegen and schema. @reaink any updates on your side?

kevscript avatar Aug 06 '22 13:08 kevscript

@kevscript Yes, I hope Prisma 4.x can be supported, currently I'm still using prisma 3.x in current nexus version

reaink avatar Aug 06 '22 16:08 reaink

I'am having the same issue upgrading 3.15.2 -> 4.21 "nexus": "1.3.0",

Error: NEXUS__UNKNOWN__TYPE was already defined and imported as a type, check the docs for extending types

kostovaljubica7 avatar Aug 17 '22 12:08 kostovaljubica7

Fix this by edit builder.js 156 change "throw extendError(typeDef.name);" to "console.log(typeDef);" Fix your nexus API with the Errors you get now.

Three backend in production @ "nexus": "^1.3.0", with "prisma": "^4.1.1",

Bjoernstjerne avatar Sep 15 '22 15:09 Bjoernstjerne

  • What is the status of this issue?
  • Has anyone solved this problem?

guog avatar Sep 29 '22 11:09 guog

Having the same issue since updating to prisma v4

zakariamofaddel avatar Oct 06 '22 13:10 zakariamofaddel

Same issue

sakhro avatar Oct 12 '22 21:10 sakhro

Have you tried my solution to remove the throw statement in the builder? Had the same issue after upgrading from 3.1x to 4.x I got some new errors by Nexus without the throw but this time with the type the error occured.

Holen Sie sich Outlook für Androidhttps://aka.ms/AAb9ysg


From: Sava-Danylo Sakhro @.> Sent: Wednesday, October 12, 2022 11:49:46 PM To: graphql-nexus/nexus @.> Cc: Björnstjerne Tiedemann @.>; Comment @.> Subject: Re: [graphql-nexus/nexus] Suport Prisma 4.0.0, Error running version nexus: 1.3.0 Error: NEXUS__UNKNOWN__TYPE was already defined and imported as a type (Issue #1119)

Same issue

— Reply to this email directly, view it on GitHubhttps://github.com/graphql-nexus/nexus/issues/1119#issuecomment-1276771640, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADMGAE7HQIFFY3A2H45LICTWC4W7VANCNFSM53Z7VNVQ. You are receiving this because you commented.Message ID: @.***>

Bjoernstjerne avatar Oct 13 '22 08:10 Bjoernstjerne

I don't think this is a prisma 4 specific error. I'm getting it any time I have more than 2 missing type definitions in my nexus schema:

To reproduce, create a field on an object of type: 'NotAType1', you'll get an error saying something about forgetting to export "NoteAType1"

Add a second field for 'NotAType2' and you'll get this error back instead and nothing about either NotAType1 or NotAType2: The below code will reproduce. Comment out the second line to see a helpful error message.

const ObjectA = objectType({
  name: 'NotImportant',
  definition(t) {
    t.string('fine');
    t.field('errorsWhenJustThis', { type: 'NotAType1' });
    t.field('unhelpfulWithThis', { type: 'NotAType2' });
  },
});

export const schema = makeSchema({
  types: [ObjectA],
  )}

rgamm avatar Oct 17 '22 18:10 rgamm

If you want, you can add detail to the error message by adding a log statement in node_modules/nexus/dist/builder.js:154

if (existingType) {
    if (existingType !== typeDef) {
        console.log(`Missing Types: ${Object.keys(this.missingTypes)}`); // <----
        throw extendError(typeDef.name);
    }
    return;
}

Might help you find the actual error

rgamm avatar Oct 18 '22 08:10 rgamm

please refer to here for the fix to this problem.

https://github.com/paljs/prisma-tools/issues/283#issuecomment-1287127772

guog avatar Oct 31 '22 10:10 guog

I'm getting this same error, I used the method here to identify what was causing the issue, and for me one of them was the DateTime type in Prisma.

SysSU avatar May 03 '23 19:05 SysSU

@SysSU I'm also getting this error with DateTime type. Did you manage to fix it?

markymc avatar Apr 18 '24 02:04 markymc

@markymc it has been some time since I looked at this code but I think the following fixed it for me.

import { makeSchema } from 'nexus';

import {
  Json as jsonScalar,
  // Import DateTime scalar
  DateTime as dateTimeScalar,
} from 'nexus-prisma/scalars';

import * as types from './types';

export default makeSchema({
  // Add dateTimeScalar to types when calling makeSchema.
  types: { ...types, jsonScalar, dateTimeScalar },
});

SysSU avatar Apr 18 '24 06:04 SysSU

@SysSU Thanks! That did it!

markymc avatar Apr 19 '24 02:04 markymc