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
Show file tree
Hide file tree
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
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 624c745

Please sign in to comment.