Skip to content

Commit

Permalink
feat!: Prisma Int @id maps to GraphQL Int (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
  • Loading branch information
lvauvillier and jasonkuhrt authored Apr 23, 2021
1 parent cffc94d commit 624c745
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/generator/models/declaration.ts
Original file line number Diff line number Diff line change
@@ -200,7 +200,8 @@ export function fieldTypeToGraphQLType(field: DMMF.Field): LiteralUnion<Standard
case 'scalar': {
const typeName = field.type as PrismaScalarType

if (field.isId) {
// TODO Allow user to configure this. Maybe some users want Prisma `Int @id` to be GraphQL `ID`.
if (field.isId && field.type === 'String') {
return StandardgraphQLScalarTypes.ID
}

Original file line number Diff line number Diff line change
@@ -852,7 +852,7 @@ export const SomeModel: $Types.SomeModel
// N/A –– You have not defined any models in your Prisma schema file."
`;

exports[`A model field with type Int, attribute @id, maps to GraphQL ID scalar 1`] = `
exports[`A model field with type Int, attribute @id, maps to GraphQL Int scalar 1`] = `
"import * as Nexus from 'nexus'
import * as NexusCore from 'nexus/dist/core'
@@ -941,7 +941,7 @@ declare namespace $Types {
/**
* The type of this field.
*/
type: NexusCore.NexusNonNullDef<'ID'>
type: NexusCore.NexusNonNullDef<'Int'>
/**
* The documentation of this field.
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ it('A model field with type String, attribute @id, maps to GraphQL ID scalar', a
expect(indexdts).toMatchSnapshot()
})

it('A model field with type Int, attribute @id, maps to GraphQL ID scalar', async () => {
it('A model field with type Int, attribute @id, maps to GraphQL Int scalar', async () => {
const { indexdts } = await generateModules(`
model SomeModel {
id Int @id

0 comments on commit 624c745

Please sign in to comment.