You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
Make sure to fork this template and run yarn generate in the terminal.
Please make sure the GraphQL Tools package versions under package.json matches yours.
2. A failing test has been provided
3. A local solution has been provided
4. A pull request is pending review
Describe the bug
At https://github.com/ardatan/graphql-tools/blob/master/packages/batch-delegate/src/getLoader.ts#L88 the fieldName seems to always be "_entities" whereas the info.fieldName seems to be the field of the extended type. Thus, the cacheKey is not unique when the selection set matches on different object types! And the wrong loader is then used which results in null values for those entities. In my opinion, the cacheKey should include the Parent Type Name (info.parentType.name) and the Info Field name (info.fieldName) and retain the concatenation of the selection set.
[I'm at a loss to understand why the fieldName variables is not equal to info.fieldName despite it being seemingly initiatize to it, but my debugger shows it is different (and the resultant behavior confirms it).]
To Reproduce Steps to reproduce the behavior:
My GraphQL query looks like:
query pq {
problemQuery {
account {
id
name
}
topic {
name
environment {
id
name
}
count
}
total
}
}
There are 3 sub-schemas stitched together:
Schema 1
type Problem {
account: Account!
topic: Topic!
total: Int
}
type Account @key(fields : "id") @extends {
id: ID! @external
}
type Environment @key(fields : "id") @extends {
id: ID!
}
type Topic @key(fields : "name environment { id }") @extends {
name: ID!
environment: Environment!
}
Schema 2
Topic @key(fields : "name environment { id }") {
name: ID!
environment: Environment!
count: Int
}
_Schema 3_
**Expected behavior**
The query should return with all the entities populated
**Environment:**
- `@graphql-tools/stitch`: 9.0.3
- NodeJS: v20.5.1
**Additional context**
The text was updated successfully, but these errors were encountered:
Issue workflow progress
Progress of the issue based on the
Contributor Workflow
Describe the bug
At https://github.com/ardatan/graphql-tools/blob/master/packages/batch-delegate/src/getLoader.ts#L88 the fieldName seems to always be "_entities" whereas the info.fieldName seems to be the field of the extended type. Thus, the cacheKey is not unique when the selection set matches on different object types! And the wrong loader is then used which results in null values for those entities. In my opinion, the cacheKey should include the Parent Type Name (info.parentType.name) and the Info Field name (info.fieldName) and retain the concatenation of the selection set.
[I'm at a loss to understand why the fieldName variables is not equal to info.fieldName despite it being seemingly initiatize to it, but my debugger shows it is different (and the resultant behavior confirms it).]
To Reproduce Steps to reproduce the behavior:
My GraphQL query looks like:
There are 3 sub-schemas stitched together:
Schema 1
Schema 2
type Account @key(fields : "id") {
id: ID!
name: String
}
type Environment @key(fields : "id") {
id: ID!
name: String
}
The text was updated successfully, but these errors were encountered: