paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
688 stars 56 forks source link

pal won't generate arguments when model name is lowercase #255

Open renaldasrep opened 2 years ago

renaldasrep commented 2 years ago

Example schema:

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
}

model Item1 {
  id        Int       @id @default(autoincrement())
}

model item2 {
  id        Int       @id @default(autoincrement())
}

graphql/Item1/queries/findUnique.ts

import { queryField, nonNull } from 'nexus'

export const Item1FindUniqueQuery = queryField('findUniqueItem1', {
  type: 'Item1',
  args: {
    where: nonNull('Item1WhereUniqueInput'),
  },
  resolve(_parent, { where }, { prisma, select }) {
    return prisma.item1.findUnique({
      where,
      ...select,
    })
  },
})

compared to:

graphql/item2/queries/findUnique.ts

import { queryField, nonNull } from 'nexus'

export const Item2FindUniqueQuery = queryField('findUniqueItem2', {
  type: 'item2',

  resolve(_parent, { where }, { prisma, select }) {
    return prisma.item2.findUnique({
      where,
      ...select,
    })
  },
})
renaldasrep commented 2 years ago

upon further investingation I found that the original issue is not what I thought it was, so I updated the name and description thankfully I can work around this quite easily