Docs
Launch GraphOS Studio

Code Generation Troubleshooting


Errors

TypeNameConflict

Example error output:

TypeNameConflict error output
TypeNameConflict - 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 or that is resulting in multiple types of the same name due to how singularization/pluralization works in code generation. Take the following schema and defintion for example:

Example Schema
type Query {
user: User
}
type User {
containers: [Container]
}
type Container {
value: Value
values: [Value]
}
type Value {
propertyA: String!
propertyB: String!
propertyC: String!
propertyD: String!
}
ConflictingQuery
query ConflictingQuery {
user {
containers {
value {
propertyA
propertyB
propertyC
propertyD
}
values {
propertyA
propertyC
}
}
}
}

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:

TypeNameConflict example code output

As the error says, the recommended way to solve this is to use a , so updating the query to be this:

ConflictingQuery
query ConflictingQuery {
user {
containers {
value {
propertyA
propertyB
propertyC
propertyD
}
valueAlias: values {
propertyA
propertyC
}
}
}
}

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:

TypeNameConflict alias example code output
Previous
Running Code Generation in Swift Code
Next
Fetching Data
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company