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
Reproduction info in README in provided link
2. A failing test has been provided
3. A local solution has been provided
4. A pull request is pending review
Describe the bug
We have defined additionalResolvers in the appropriate file such as: Header_ID_V5_V4: { deprecated: mapFromField('original'), },
This field is defined in the schema as:
@ObjectType()
export class Header_ID_V5_V4 {
[...] //left out some fields
@Field(() => String, {
nullable: false,
})
original!: string;
@Field(() => String, {
deprecationReason: "('use original instead')",
nullable: true,
})
deprecated!: string | null;
}
Where mapFromField is defined as (effectively it is just a pushdown of an additional selection, as a field has been deprecated and we have changed the naming, therefore we do the mapping in the gateway, as it was the easiest way to solve this generically):
/**
* Maps a field to another 1:1
* @param originalFieldName the original field's name
* @returns the field's value
*/
export function mapFromField(
originalFieldName: string
) {
return {
selectionSet: `
{
${originalFieldName}
}`,
resolve(root) {
return root[originalFieldName];
},
};
}
However, running this code, the result is not as expected as deprecated is not filled. This is due to original not being pushed to the subgraph, as expected. A check in onFetch shows that the field is not part of info.fieldNodes, which I would have expected. In the subgraph, the selectionSet also does not define original but instead only deprecated.
To Reproduce Steps to reproduce the behavior:
Create a simple selectionSet on oneField with a definition as above and try to map it. It will not work :-(
Expected behavior
In previous versions, e.g. this resolved correctly. I would have expected original being send to the subgraph.
Issue workflow progress
Progress of the issue based on the
Contributor Workflow
Github
Describe the bug
We have defined additionalResolvers in the appropriate file such as:
Header_ID_V5_V4: { deprecated: mapFromField('original'), },
This field is defined in the schema as:
Where mapFromField is defined as (effectively it is just a pushdown of an additional selection, as a field has been deprecated and we have changed the naming, therefore we do the mapping in the gateway, as it was the easiest way to solve this generically):
However, running this code, the result is not as expected as
deprecated
is not filled. This is due tooriginal
not being pushed to the subgraph, as expected. A check inonFetch
shows that the field is not part ofinfo.fieldNodes
, which I would have expected. In the subgraph, the selectionSet also does not defineoriginal
but instead onlydeprecated
.To Reproduce Steps to reproduce the behavior:
Create a simple selectionSet on oneField with a definition as above and try to map it. It will not work :-(
Expected behavior
In previous versions, e.g. this resolved correctly. I would have expected
original
being send to the subgraph.Environment:
We are using the following versions:
v18
Additional context
Was working fine in previous versions.
The text was updated successfully, but these errors were encountered: