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

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

Open
reaink opened this issue Jul 17, 2022 · 17 comments

Comments

@reaink
Copy link

reaink commented Jul 17, 2022

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

@recklyss
Copy link

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

@reaink
Copy link
Author

reaink commented Jul 27, 2022

current version

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

update to prisma v4.x throw error NEXUS__UNKNOWN__TYPE

@kevscript
Copy link

kevscript commented Aug 6, 2022

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?

@reaink
Copy link
Author

reaink commented Aug 6, 2022

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

@kostovaljubica7
Copy link

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

@Bjoernstjerne
Copy link

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",

@guog
Copy link

guog commented Sep 29, 2022

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

@zakariamofaddel
Copy link

Having the same issue since updating to prisma v4

@sakhro
Copy link

sakhro commented Oct 12, 2022

Same issue

@Bjoernstjerne
Copy link

Bjoernstjerne commented Oct 13, 2022 via email

@rgamm
Copy link

rgamm commented Oct 17, 2022

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
Copy link

rgamm commented Oct 18, 2022

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

@guog
Copy link

guog commented Oct 31, 2022

please refer to here for the fix to this problem.

paljs/prisma-tools#283 (comment)

@SysSU
Copy link

SysSU commented May 3, 2023

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.

@markymc
Copy link

markymc commented Apr 18, 2024

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

@SysSU
Copy link

SysSU commented Apr 18, 2024

@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 },
});

@markymc
Copy link

markymc commented Apr 19, 2024

@SysSU Thanks! That did it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests