ChilliCream / ChilliCream/graphql-platform

Conflict with mismatching connections with same name

Open
#6,871 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Data
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction in HotChocolateBugRepro.zip and the two GetFriends methods using UsePaging. Inspect how the schema builds the inferred FriendsConnection for the Hero and Villain fields, then reproduce the generated schema shown in the issue. Done means incompatible same-named connections produce an error instead of silently sharing one connection type.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, graphql
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.