Code Generation Troubleshooting
Errors
TypeNameConflict
Example error output:
Text
TypeNameConflict error output
1TypeNameConflict - Field 'values' conflicts with field 'value' in operation/fragment `ConflictingQuery`. Recommend using a field alias for one of these fields to resolve this conflict.
If you receive this error, you have an Operation or Fragment that is resulting in multiple types of the same name due to how singularization/pluralization works in code generation. Take the following schema and query defintion for example:
GraphQL
Example Schema
1type Query {
2 user: User
3}
4
5type User {
6 containers: [Container]
7}
8
9type Container {
10 value: Value
11 values: [Value]
12}
13
14type Value {
15 propertyA: String!
16 propertyB: String!
17 propertyC: String!
18 propertyD: String!
19}
GraphQL
ConflictingQuery
1query ConflictingQuery {
2 user {
3 containers {
4 value {
5 propertyA
6 propertyB
7 propertyC
8 propertyD
9 }
10
11 values {
12 propertyA
13 propertyC
14 }
15 }
16 }
17}
If you run code generation with these you will get the TypeNameConflict
error because the generated code for your query would contain code that looks like this:
As the error says, the recommended way to solve this is to use a field alias, so updating the query to be this:
GraphQL
ConflictingQuery
1query ConflictingQuery {
2 user {
3 containers {
4 value {
5 propertyA
6 propertyB
7 propertyC
8 propertyD
9 }
10
11 valueAlias: values {
12 propertyA
13 propertyC
14 }
15 }
16 }
17}
If you run the code generation with the update query you will no longer see the error and the resulting code will look like this: