Description
Describe the bug
I am encountering "conflicting definition" errors when using specific GraphQL field and type names with genqlient. The error message is as follows:
...../schema.graphql:13: conflicting definition for FooBarA; this can indicate either a genqlient internal error, a conflict between user-specified type-names, or some very tricksy GraphQL field/type names: expected 2 fields, got 1
exit status 1
main.go:9: running "go": exit status 1
To Reproduce
The issue occurs under specific conditions:
- The schema includes a union whose name is the concatenation of a parent type's name and its field names in camel case.
- The query includes fragments named identically to the types:
For a clearer understanding and a practical demonstration, I prepared a minimal reproducible example here: https://github.com/Ynng/genqlient-bug
Expected behavior
I expect the code generation process to successfully handle these scenarios without encountering conflicting definition errors.
genqlient version
v0.6.0
Additional Information
My guess is that the issue arises when convertDefinition()
encounters a name
that is the same as namePrefix
list concatenated and formatted.
This causes problems down the road for Unions, leading to duplicate "UnionNameImplName" definitions.
I think the issue can be traced back to these two lines:
Line 465 in 28aafc7
Line 496 in 28aafc7
These lines inadvertently create two conflicting definitions: one from "UnionName + ImplName" and another from "Union + Name + ImplName."