Skip to content

model class generation for case sensitive names #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Teja6028 opened this issue Apr 13, 2021 · 8 comments
Closed

model class generation for case sensitive names #651

Teja6028 opened this issue Apr 13, 2021 · 8 comments
Assignees
Labels
question Further information is requested

Comments

@Teja6028
Copy link

Teja6028 commented Apr 13, 2021

Currently we have a graphql schema with case sensitive types and maven-plugin is failing while generating model classes saying file already exisits.

Solution I think of is
Generate packages for model classes based on graphql schema that way it won't class on duplicate files.

@kobylynskyi
Copy link
Owner

kobylynskyi commented Apr 14, 2021

Hi @Teja6028
Could you please provide a sample schema so that we can reproduce the issue? Thanks

@Teja6028
Copy link
Author

Hi.. Below is the sample schema I was referring to

schema {
query: Query
}

type Query {
productById(id: ID!): Product
}

type Product {
id: ID!
title: String!
description: String
priceDetails: PriceDetails
}

type PriceDetails {
quantity: String
rate: Int
PRICEDETAILS: PRICEDETAILS
}

type PRICEDETAILS {
PRICEPERITEM: Int
TOTALPRICE: Int
}

@jxnu-liguobin
Copy link
Collaborator

In my humble opinion, there is something wrong with this schema design. 😅

@kobylynskyi
Copy link
Owner

Agree with @jxnu-liguobin

@kobylynskyi kobylynskyi added the question Further information is requested label Apr 14, 2021
@Teja6028
Copy link
Author

Can you explain me what you think is wrong in the schema.. Is it same types with case sensitivity or anything else?

But I read Graphql supports case sensitive names..

@robbertnoordzij
Copy link
Contributor

I tried your sample schema with the maven plugin on java 11 on a linux machine. This works fine. I suspect that you are using an Windows based system in which filenames are case insensitive.So this is not an issue with the code gen or java, I think.

However, to me as an engineer the naming does not seem self explanatory. On a glance, I can not see the difference between the PRICEDETAILS and PriceDetails by just the name of the type.

I would suggest something like:

type OrderLine {
    quantity: String
    rate: Int
    pricePerItem: Int
    totalPrice: Int
}

Especially since there is no relation between the pricePerItem and totalPrice without the quantity (which is in the parent).

@Teja6028
Copy link
Author

Thanks for that @robbertnoordzij

@kobylynskyi kobylynskyi added invalid This doesn't seem right and removed question Further information is requested labels Apr 16, 2021
@kobylynskyi kobylynskyi added question Further information is requested and removed invalid This doesn't seem right labels Apr 16, 2021
@yeikel
Copy link
Contributor

yeikel commented Jun 28, 2023

I stumbled into this one

Example types within the same schema

type Hierarchy {

}

type hierarchy {

}

I agree with the sentiment that this design is poor, but sadly there is little I can do at this point because the application is in production accepting traffic and renaming it would be a breaking change

Caused by: java.nio.file.FileAlreadyExistsException: File already exists: /graphql/model/Hierarchy.java

The solution at this point (without a change in schema) is unclear, but I would be happy with some workaround such as append a suffix to the model class

@kobylynskyi I can create a new issue if that makes more sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants