graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Interface type subscriptions throw an error: The topic already exists with a different message type.

Open grounzero opened this issue 1 year ago • 0 comments

Product

Hot Chocolate

Version

13.8.1

Link to minimal reproduction

https://github.com/grounzero/hcsubscriptions/

Steps to reproduce

  1. Run the repro project and visit https://localhost:7015/graphql/

  2. Subscribe to BookUpdated with the following arguments:


subscription BookUpdated {
  bookUpdated(id: "2") {
    ... on PagesBook {
      title
      author {
        name
      }
      pages
    }
    ... on AnotherBook {
      title
      author {
        name
      }
      another
    }
  }
}

  1. Run AddPagesBook with the following arguments:

mutation AddPagesBook {
  addPagesBook(
    input: { id: "2", author: { name: "name" }, pages: 100, title: "title1" }
  ) {
    title
    author {
      name
    }
    pages
  }
}

  1. Run AddAnotherBook with the following arguments which throws an exception which can occur in either AddPagesBook or AddAnotherBook mutation depending on which id value is passed to BookUpdated subscription.
InvalidMessageTypeException: 'The topic already exists with a different message type. Topic message type: hcsubscriptions.Types.Book. Requested message type: hcsubscriptions.Types.AnotherBook.'

mutation AddAnotherBook {
  addAnotherBook(
    input: {
      id: "3"
      author: { name: "name" }
      another: "another"
      title: "title2"
    }
  ) {
    title
    author {
      name
    }
    another
  }
}

What is expected?

The subscription should return the appropriate interface implementation

What is actually happening?

An exception is thrown:

InvalidMessageTypeException: 'The topic already exists with a different message type.
Topic message type: hcsubscriptions.Types.Book.
Requested message type: hcsubscriptions.Types.AnotherBook.'

Relevant log output

No response

Additional context

No response

grounzero avatar Feb 01 '24 14:02 grounzero