Skip to content

Conflict with mismatching connections with same name #6871

@cmeeren

Description

@cmeeren

Product

Hot Chocolate

Version

13.8.1

Link to minimal reproduction

See zip below

Steps to reproduce

Minimal repro: HotChocolateBugRepro.zip

Code for quick reference:

public class Hero()
{
    [UsePaging(IncludeTotalCount = true)]
    public IEnumerable<Hero> GetFriends() => [];
}

public class Villain()
{
    [UsePaging(RequirePagingBoundaries = true)]
    public IEnumerable<Villain> GetFriends() => [];
}

public class Query
{
    public IEnumerable<Hero> GetHeroes() => [];
    public IEnumerable<Villain> GetVillains() => [];
}

What is expected?

Since the two connections are inferred to have the same name, but are incompatible (different node types and/or other data such as the total field and required inputs), an error should be raised.

What is actually happening?

HotChocolate seems to silently pick one edge type and ignore the other.

Resulting schema for quick reference:

Expand
type Query {
  heroes: [Hero!]!
  villains: [Villain!]!
}

type Villain {
  friends(
    """
    Returns the first _n_ elements from the list.
    """
    first: Int

    """
    Returns the elements in the list that come after the specified cursor.
    """
    after: String

    """
    Returns the last _n_ elements from the list.
    """
    last: Int

    """
    Returns the elements in the list that come before the specified cursor.
    """
    before: String
  ): FriendsConnection
}

type Hero {
  friends(
    """
    Returns the first _n_ elements from the list.
    """
    first: Int

    """
    Returns the elements in the list that come after the specified cursor.
    """
    after: String

    """
    Returns the last _n_ elements from the list.
    """
    last: Int

    """
    Returns the elements in the list that come before the specified cursor.
    """
    before: String
  ): FriendsConnection
}

"""
A connection to a list of items.
"""
type FriendsConnection {
  """
  Information to aid in pagination.
  """
  pageInfo: PageInfo!

  """
  A list of edges.
  """
  edges: [FriendsEdge!]

  """
  A flattened list of the nodes.
  """
  nodes: [Villain!]
}

"""
Information about pagination in a connection.
"""
type PageInfo {
  """
  Indicates whether more edges exist following the set defined by the clients arguments.
  """
  hasNextPage: Boolean!

  """
  Indicates whether more edges exist prior the set defined by the clients arguments.
  """
  hasPreviousPage: Boolean!

  """
  When paginating backwards, the cursor to continue.
  """
  startCursor: String

  """
  When paginating forwards, the cursor to continue.
  """
  endCursor: String
}

"""
An edge in a connection.
"""
type FriendsEdge {
  """
  A cursor for use in pagination.
  """
  cursor: String!

  """
  The item at the end of the edge.
  """
  node: Villain!
}

Relevant log output

No response

Additional context

Note that I am aware how to override the connection name with ConnectionName.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DataIssue is related to filtering, sorting, pagination or projections🌶️ hot chocolate

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions