nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.45k stars 394 forks source link

TypeScript definitions generated with wrong case #3147

Open domusofsail opened 8 months ago

domusofsail commented 8 months ago

Is there an existing issue for this?

Current behavior

In a schema-first approach, given a GraphQL schema having a lowercase type, the Typescript definitions generated have inconsistent case between class definition and method return types.

Given the following schema:

type person {
  name: String
  surname: String
}

type Query {
  persons(search: String!): [person!]!
}

the following Typescript gets generated:

export class Person {
    name?: Nullable<string>;
    surname?: Nullable<string>;
}

export abstract class IQuery {
    abstract persons(search: string): person[] | Promise<person[]>;
}

resulting in a Typescript error TS2552: Cannot find name 'person'. Did you mean 'Person'?

image

Minimum reproduction code

https://github.com/domusofsail/nestjs-graphql-example

Steps to reproduce

pnpm start:dev

Expected behavior

Either class generated lowercase, or return type generated uppercase.

Package version

12.1.1

Graphql version

graphql: 16.8.1 apollo-server-express: N/A apollo-server-fastify: N/A

NestJS version

10.0.0

Node.js version

20.11.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 8 months ago

Would you like to create a PR for this issue?

domusofsail commented 8 months ago

Ok, I'll try to do my best.