[C# operations] - generates duplicate classes
#105 opened on Feb 15, 2021
Repository metrics
- Stars
- (136 stars)
- PR merge metrics
- (PR metrics pending)
Description
Describe the bug When more properties of the same type are included in the same query/mutation, generator outputs duplicated classes with the same name in result cs file
To Reproduce
-
Include more fields with the same non-primitive type but different name in the schema
-
Make query/mutation to return all of the fields with the same type
-
Generate result cs file Using example data in this issue, it generates TestSelection class 2-times in the same subclass which results to syntax error in C#.
-
My GraphQL schema:
scalar Date
schema {
query: Query
}
type Query {
me: User!
another: User!
user(id: ID!): User
allUsers: [User]
search(term: String!): [SearchResult!]!
myChats: [Chat!]!
}
enum Role {
USER,
ADMIN,
}
interface Node {
id: ID!
}
union SearchResult = User | Chat | ChatMessage
type User implements Node {
id: ID!
username: String!
email: String!
role: Role!
test1: Test!
test2: Test!
}
type Test{
id: ID!
message: String!
}
type Chat implements Node {
id: ID!
users: [User!]!
messages: [ChatMessage!]!
}
type ChatMessage implements Node {
id: ID!
content: String!
time: Date!
fromUser: User!
toUser: User!
}
- My GraphQL operations:
query findUser($userId: ID!) {
user(id: $userId) {
...UserFields
}
}
fragment UserFields on User {
id
username
role
test1{
id
}
test2{
id
}
}
- My
codegen.ymlconfig file:
generates:
src/main/c-sharp/my-org/my-app/Operations.cs:
plugins:
- c-sharp-operations
config:
typesafeOperation: true
Expected behavior "Selection" classes should be named by fieldName instead of fieldType =>
- public class Test1Selection
- public class Test2Selection
Environment:
@graphql-codegen/c-sharp-operations: