Open 0xsven opened 3 years ago
I ran into the same issue after upgrading from 2.13
to 2.17
, but for me it was only SortOrder
.
The underlying issue seems to be that in the latest version of Prisma, SortOrder
is no longer exported at the top level. It is exported under the namespace Prisma
. Comparing 2.17 v.s 2.13 below.
node_modules/.prisma/client/index.d.ts
export namespace Prisma {
// ... a lot of stuff here
export const SortOrder: {
asc: 'asc',
desc: 'desc'
};
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
}
node_modules/.prisma/client/index.d.ts
// ..same as above, but also exports type SortOrder, mentioning that it is deprecated
/**
* @deprecated Renamed to `Prisma.SortOrder`
*/
export type SortOrder = Prisma.SortOrder
I can fix this by manually changing the generated file like below
export interface NexusGenEnums {
SortOrder: Prisma.Prisma.SortOrder // <-- this fixes it
}
But that is not ideal.
This workaround is what was recommended to me too by maintainers of Prisma. Also, I would like to point out, that the error is type-check error only and the code will still output working code, as such it can be safely ignored as long as builds outputs files.
This file is generated by the system. How would you permanently change it?
@0xsven You don't... You have to edit it after every generation... We can only hope this will get fixed...
Another workaround is to set "skipLibCheck": true
in your typescript compilerOptions.
@jasonkuhrt Would you mind looking into this? It is currently breaking every server build (I had to create bash utility to replace prisma.SortOrder
to prisma.Prisma.SortOrder
...)
I know that you (as prisma) are working on a new plugin, but this will help in the meantime. it should be a simple fix :)
@0xsven @Akxe
You can solve this problem by changing the output of makeSchema.
typegen: path.join(__dirname.'/api/nexus-typegen.ts')
-> typegen: path.join(__dirname.'/api/nexus-typegen.d.ts')
Generated Artifacts:
TypeScript Types ==> /api/nexus-typegen.d.ts
GraphQL Schema ==> /api/schema.graphql
nexus-typegen.ts:605:21 - error TS2694: Namespace '"/api/node_modules/.prisma/client/index"' has no exported member 'QueryMode'.
605 QueryMode: prisma.QueryMode
~~~~~~~~~
nexus-typegen.ts:607:21 - error TS2694: Namespace '"/api/node_modules/.prisma/client/index"' has no exported member 'SortOrder'.
607 SortOrder: prisma.SortOrder
~~~~~~~~~
Found 2 errors.
@ltnscp9028 doesnt work for me
This package is basically archivated for now, use this workaround:
ts-node -r tsconfig-paths/register --transpile-only ./schema.ts && npx replace-in-file prisma.SortOrder prisma.Prisma.SortOrder **/nexus.generated.ts
Rename the file to your file and if multiple replacements must be made, copy the command twice... not great, but it will do the job for now.
This worked fine. Thank you!
"build:replace": "replace-in-file prisma.SortOrder prisma.Prisma.SortOrder **/nexus-typegen.ts && replace-in-file prisma.QueryMode prisma.Prisma.QueryMode **/nexus-typegen.ts",
@Akxe @0xsven nice hack with replace-in-file, but it doesn't trigger when nexus is generated by the dev server on model/api change.
To use nexus-plugin-prisma with prisma above 2.14, we can override .prisma/client
typescript module resolution and inject both QueryMode
and SortOrder
properties:
"compilerOptions": {
"paths": {
".prisma/client": ["utils/fix-prisma-client-for-nexus.ts"]
}
}
/* eslint-disable import/no-relative-packages */
import { Prisma } from '../../node_modules/.prisma/client';
export * from '../../node_modules/.prisma/client';
// Fix nexus-plugin-prisma using QueryMode/SortOrder moved in prisma 2.15
// See https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1056
export type SortOrder = Prisma.SortOrder;
export type QueryMode = Prisma.QueryMode;
export const { SortOrder, QueryMode } = Prisma;
I replaced the types in makeSchemas
mapping
property - works perfectly:
export const schema = makeSchema({
// ... rest of makeSchema config
mapping: {
//...all custom scalars
SortOrder: 'prisma.Prisma.SortOrder',
QueryMode: 'prisma.Prisma.QueryMode',
},
},
Amazing fix @chrishoermann thank you!
Since I have upgraded my dependencies to...
... I am getting the following error when transpiling my app:
My workaround is to downgrade prisma client like so:
Somehow prisma client 2.15.0 introduced a change that breaks my build. Any ideas what I am missing?