Closed flamedmg closed 1 year ago
Hey @flamedmg, this is technically not a bug. Fields of input types and object types are different fields. There's already a feature implemented under the hood to configure the scalar mapping globally. This feature is unfortunately not exposed on the framework plugin yet. We need to expose it to allow your use-case. Would the API below solve your issue?
import { prisma } from 'nexus-plugin-prisma'
prisma({
scalars: {
Int: scalarType({ name: 'Long', /* ... */ })
}
})
Hello, @Weakky ! Thank you for you help. Your proposed solution does not work. I used it like this:
import { nexusSchemaPrisma } from 'nexus-plugin-prisma/schema'
import { prisma } from 'nexus-plugin-prisma'
import { makeSchema } from '@nexus/schema'
import * as types from './types'
prisma({
scalars: {
Int: scalarType({ name: 'Long', /* ... */ })
}
})
export const schema = makeSchema({
types:[
types,
],
plugins: [nexusSchemaPrisma({
experimentalCRUD: true, // required!
paginationStrategy: "prisma", // required!
})],
outputs: {
schema: __dirname + '/../schema.graphql',
typegen: __dirname + '/generated/nexus.ts',
},
typegenAutoConfig: {
sources: [
{
source: '@prisma/client',
alias: 'client',
},
{
source: require.resolve('./context'),
alias: 'Context',
},
],
contextType: 'Context.Context',
},
})
I got the following error:
Using ts-node version 8.10.1, typescript version 3.9.5
ReferenceError: scalarType is not defined
at Object.<anonymous> (/Users/dmg/Projects/tmp/graphql-auth/src/schema.ts:9:10)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Module._compile (/Users/dmg/Projects/tmp/graphql-auth/node_modules/source-map-support/source-map-support.js:547:25)
at Module.m._compile (/private/var/folders/2d/rhs74gk94bv_cvb81jzhwq_40000gn/T/ts-node-dev-hook-4641486286105545.js:57:25)
at Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at require.extensions.<computed> (/private/var/folders/2d/rhs74gk94bv_cvb81jzhwq_40000gn/T/ts-node-dev-hook-4641486286105545.js:59:14)
at Object.nodeDevHook [as .ts] (/Users/dmg/Projects/tmp/graphql-auth/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
[ERROR] 20:24:29 ReferenceError: scalarType is not defined
The proposed solution is a proposal, not something already implemented. The question was:
Would the API below solve your issue?
Yes, it will!
On Mon, Jul 20, 2020 at 5:16 PM Flavian Desverne notifications@github.com wrote:
The proposed solution is a proposal, not something already implemented. The question was:
Would the API below solve your issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/graphql-nexus/nexus/issues/1111#issuecomment-661067394, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADFVCJOPJZPUF2I5N4GA73R4RGUDANCNFSM4OIN73LA .
-- Thanks & Regards Dmitry
@Weakky I'm also facing the same issue. Is it resolved now?
Nexus Report
Description
Actual database is mysql and uses bigint for all ids. What i'm trying to achive is to make bigint ids to work. If numbers that are placed in id can be fitted in int32 - everything seems to work good, but if there are numbers that are greater then that, graphql refusing to work and complaining that it can't fit number into int32
Please consider the following prisma.schema
nexus definitions are straight forward. The only difference is that i added crud operations. To handle bigint values i created custom scalar type:
User definition is as follows:
Nexus properly generates User schema which looks like this:
But crud types are generated using prisma.schema defined types instead of defined in users objectType