HoudiniGraphql/houdini

List operations with hop to parent

SeppahBaws opened this issue · 1 comments

Describe the bug

A part of our schema looks something like this:

type Organization implements Node {
  id: ID!
  name: String!
  module1Settings: Module1Settings!
  # more fields...
}

type Module1Settings {
  # Note the lack of an ID field here...
  someConnection(first: Int, after: String, last: Int, before: String): SomeOtherTypeConnection!
}

The reason for this is that in the database, these properties are stored straight on the Organization table, but for ease of use in the API, we're adding a shadow type (Module1Settings).

The problem is that when I add a @list on this someConnection field, the cache doesn't find the correct list.

Debugging the ListManager.get method, I see that it gets the correct lists:

[
  { recordID: "Organization:org1Id.module1Settings", recordType: "Module1Settings", ... },
  { recordID: "Organization:org2Id.module1Settings", recordType: "Module1Settings", ... },
]

When it tries to get the parentID on L41:

const parentID = id ? this.cache._internal_unstable.id(recordType || '', id)! : this.rootID

it returns Module1Settings:org1Id. Then it tries to find a list where that parentID matches, which of course will fail, since the correct parentID should be Organization:org1Id.

For now I can work around it with simply not using the list operations and manually refetching the original query, but it feels like something that Houdini should be able to handle somehow...

Reproduction

(will try to create one later)