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
For example, we have list of documents. Each Document has a collection of DocumentSpecification (stored in another database table). So after query being projected, there is need to populate Specifications property, which will not be passed to client.
[UseProjection]publicasyncTask<IReadOnlyCollection<Document>>GetDocuments(DocumentsInputinput,[Service(ServiceKind.Resolver)]DocumentDbContextdbContext,IResolverContextcontext){varq=(fromdocindbContext.Documentswhere// Some of good conditions with values from input object.selectdoc);// Throws the exception:// Cannot apply the 'Include' operation with argument 'x => x.Specifications',// ...consider applying 'Include' before 'Select' method call.//var documents =await q.Project(context).Include(x =>x.Specifications).AsNoTracking().ToListAsync();
var filteredDocuments =fromdocindocumentswhere!doc.Specifications.Any()||doc.Specifications.All(x =>x.IsSatisfiedBy(input))selectdoc;returnfilteredDocuments.ToList();}
I know, there is a way to create ObjectType<Document> with always-projected field by IsProjected(true). But how to achieve that behavior for standalone query and not for all other, where Document being fetched?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For example, we have list of documents. Each
Document
has a collection ofDocumentSpecification
(stored in another database table). So after query being projected, there is need to populateSpecifications
property, which will not be passed to client.I know, there is a way to create
ObjectType<Document>
with always-projected field byIsProjected(true)
. But how to achieve that behavior for standalone query and not for all other, where Document being fetched?HotChocolate v13.0.5
Beta Was this translation helpful? Give feedback.
All reactions