Let say i have employees under root query (Parent-> Child-> employees (...variables) {_id name email}
) somewhere. I would like to load all the employee using my custom query in typepolicity.
I tried to play with toRefernce without passing any Id since I want to load all the employee but was not successfull.
Query: {
fields: {
myCustomLoadAllTheEmployee(_, { args, toReference }): unknown {
return toReference({
__typename: 'Employee',
});
},
}
}
So, my question is, how can I load all the entities when I only know the __typename.?
There's no good way to do this right now (toReference
needs not only the __typename
but also any primary key fields, and only returns a reference to a single object), but I agree it would be useful to have some way of querying the cache that goes beyond what GraphQL query syntax allows. Of course, that would make the cache feel more like a general-purpose graph database, which raises all sorts of possibilities, like building indexes on certain fields (like __typename
) to improve performance.
Most helpful comment
There's no good way to do this right now (
toReference
needs not only the__typename
but also any primary key fields, and only returns a reference to a single object), but I agree it would be useful to have some way of querying the cache that goes beyond what GraphQL query syntax allows. Of course, that would make the cache feel more like a general-purpose graph database, which raises all sorts of possibilities, like building indexes on certain fields (like__typename
) to improve performance.