-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[useResponseCache] Ignore specfic schemaCoordinates for IdFields which are not the root of a subgraph #2247
Comments
Hi! Thank you for reaching out on this! Can you provide a simple reproduction of this behavior ? The response cache is using IDs for its automatic cache invalidation and should not impact the other field of the entity. This mechanism works well most of the time, but if some cases doesn't fit this paradigm, you can manually invalidate response by calling |
Hey, thanks for the fast response For clarification, this has nothing todo with invalidation. The object is not even cached in this case as ttl = 0. In the Step: # envelop/packages/plugins/response-cache/src/plugin.ts Lines 364 to 365 in de4d13b
the field "id" is picked up for the "header" Object. And is therefore resolved as if header is a cached item ( which it isn't, its just common field for all our Objects). This causes the header object which is returned from our data source to be overwritten and returned as null. If the query does not contain the header(id) field, the Header.Id coordinate is not added to 'idFieldByTypeName' all is resolved normally. |
Update: Hope this helps, the fork has the "fix" for this issue. While coding I encountered the "ignoreTypes" parameter which ignores the caching for given types. I do wan't the object to be cached though. |
Would you create a PR? |
sure, will finish my tests by tomorrow and create the PR |
created pull request |
Pull request provided a reproduction and fix to the Issue. Can I get an update @ardatan ? On what to do next ? |
Is your feature request related to a problem? Please describe.
In our schema we have fields named "id" which are not part of a subgraph, just a nested field named "id". This causes the caching-plugin to treat this nested field like a subgraph, which results in the nested field always beeing null.
Describe the solution you'd like
Add a new optionalList of schemaCoordinates to the useResponseCacheParamters, which is used to exclude fields on specific objects in the mapSchema step. Can provide a pull request.
Alternative solution which we tried (and worked) was renaming all "id" fields which are not a root of a subgraph in our schema. Which sadly is not a solution wie can deploy.
The text was updated successfully, but these errors were encountered: