Description
Describe the bug
When enabling mesh sdk caching using redis, or caching on any underlying service the mesh queries. If we alias a field then the Mesh SDK query itself fails with a null error for the particular aliased field.
GraphQL Mesh SDK Failed (1 errors): Cannot return null for non-nullable field component_configs_selector_field.selector_fields
The alias looks like this
selector {
fields: selector_fields(order_by: { order_by: asc }) {
type
title
}
}
After investigating it only seems to happen on Redis. The file and inmemory cache both seem to be working as expected with aliased fields returning no problem.
I confirmed it was an alias field issue by going into a Redis GUI and changing the cached response from something like
"selector":{
"fields":[]
}
To the original unaliased name and that fixed the error (running into an error on the next aliased field though since we rely on aliases heavily.
"selector":{
"selector_fields":[]
}
To Reproduce
Alias a GraphQL field and use a redis cache (in our case running on a docker pod inside kubernetes).
Expected behavior
Redis caching should work as expected when hooked up via the Mesh SDK Cache config, or when redis caching is enabled on the underlying service itself (i.e our underlyding federated ApolloServer pod)
Environment:
- OS:
- "@apollo/federation": "^0.14.1",
"@apollo/gateway": "^0.14.1", - "@graphql-mesh/cache-file": "^0.5.10",
"@graphql-mesh/cache-inmemory-lru": "^0.5.5",
"@graphql-mesh/cache-redis": "^0.5.10",
"@graphql-mesh/cli": "^0.2.15",
"@graphql-mesh/config": "^0.4.1",
"@graphql-mesh/graphql": "^0.2.15",
"@graphql-mesh/runtime": "^0.2.15",
"@graphql-mesh/transform-cache": "^0.9.0", - NodeJS: 13.14.0
Additional context
Pretty sure it's an issue directly related to aliases, it is working fine on all other tested caching solutions. Even though the cached response is exactly the same, for example I pulled this from the file cache
{
"selector":{
"fields: [{... data ...}]
}
]
I'm available to help fix the bug and support as required as this is a high priority issue for our company releasing GraphQL Mesh to production soon. I will just need to be pointed in the right direction, or if you are able to fix the issue no worries. Let me know if/how I can help.