Skip to content

convertDefinition failing when name == concatenated namePrefix  #305

Open
@Ynng

Description

@Ynng

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:

  1. The schema includes a union whose name is the concatenation of a parent type's name and its field names in camel case.
  2. 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:

sharedFields, err := g.convertSelectionSet(

implTyp, err := g.convertDefinition(

These lines inadvertently create two conflicting definitions: one from "UnionName + ImplName" and another from "Union + Name + ImplName."

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions