graphql-mesh
graphql-mesh copied to clipboard
Renamed input type field on graphql source is missing when using multiple sources
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
https://codesandbox.io/p/devbox/eloquent-dew-l57vz8
Make sure to fork this template and run
yarn generate
in the terminal.Please make sure Mesh 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
This issue comes as a side-effect of the workaround used on the issue I reported in #6877.
I want to rename the field txName in the Treatment type to name and in the TreatmentBoolExp input type. Effectively going from:
type Treatment {
txName: String
}
input TreatmentBoolExp {
txName: StringComparisonExp
}
to:
type Treatment {
name: StringComparisonExp
}
The workaround for #6877 was to keep the dummy json schema source. However, if that's in place the query sent to my source is reformatted and the arguments are moved onto variables.
Eg, given this query:
{
treatments(where: {
id: { _isNull: true }
name: { _eq: "Test" }
}) {
id
name
}
}
If the dummy json schema is in place, the source graphql server gets:
{
"query": "query ($_v0_where: TreatmentBoolExp) {\n treatments(where: $_v0_where) {\n id\n name: txName\n }\n}",
"variables": {
"_v0_where": {
"id": {
"_isNull": true
}
}
}
}
I instead, the dummy source isn't place, it gets this:
{
"query": "{\n treatments(where: {id: {_isNull: true}, txName: {_eq: \"Test\"}}) {\n id\n name: txName\n }\n}",
"variables": {}
}
Which is what I would expect graphql-mesh would send to my server.
To Reproduce Steps to reproduce the behavior:
If you toggle the Hello World source on/off you'll be able to test it alright. I added a dummy graphql endpoint server that returns the body it got sent in Treatment.name.
Expected behavior
The expected behaviour is that graphql-mesh send the query including renamed variables.
Environment:
- OS: macOS 14.4.1 (23E224) (local)/on codesanbox it's whatever it uses
- "@graphql-mesh/cli": "0.89.9",
- "@graphql-mesh/graphql": "^0.97.5",
- "@graphql-mesh/json-schema": "0.99.6",
- "@graphql-mesh/transform-rename": "^0.97.5",
- "@graphql-mesh/transform-replace-field": "^0.97.5",
- NodeJS: v18.16.0 (local)/v20.12.0 (codesandbox)
Additional context
It all comes back to the original issue caused by using rename and replace-field together on the source.
Thanks!