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
[...] keyFields strings always refer to the actual field names as defined in your schema, meaning the ID computation is not sensitive to field aliases.
I'm in somewhat of a corner case here. Because of a lack of UUIDs on some of my schema models, I'm using typePolicy's keyFields to configure an association of keys that are unique as the key.
This works fine when I'm actually querying these fields as-is, but if in my query I aliased the author key to user, Apollo throws the following error when trying to call toReference() in another resolver's merge function:
Note that it was not trivial to figure out, since there was no explicit message. Some searching led me to #6665 where I would eventually find the complete expected error message in @benjamn's reply: #6665 (comment). I guess the error I'm looking at is actually the key 3 on his snippet.
Intended outcome:
keyFields should work for nested keys when using an alias.
Actual outcome:
keyFields is unable to resolve nested keys when using an alias along the path.
How to reproduce the issue:
setup a type policy keyFields with nested field. Example: ["title", "author", ["name"]]
query an object of this type but instead of querying author directly, use an alias. Example: user: author
call toReference() with the resulting object. Example: in a merge() field policy.
According to the cache configuration docs:
I'm in somewhat of a corner case here. Because of a lack of UUIDs on some of my schema models, I'm using typePolicy's
keyFields
to configure an association of keys that are unique as the key.Here's an example configuration:
This works fine when I'm actually querying these fields as-is, but if in my query I aliased the
author
key touser
, Apollo throws the following error when trying to calltoReference()
in another resolver'smerge
function:Intended outcome:
keyFields
should work for nested keys when using an alias.Actual outcome:
keyFields
is unable to resolve nested keys when using an alias along the path.How to reproduce the issue:
keyFields
with nested field. Example:["title", "author", ["name"]]
author
directly, use an alias. Example:user: author
toReference()
with the resulting object. Example: in amerge()
field policy.Versions
The text was updated successfully, but these errors were encountered: