Ich möchte ein benutzerdefiniertes Modell zurückgeben, nicht einen Sammelsegmenttyp. Dies ist mein Resolver, um Sortieren, Filtern, Pagination und Projektion anzuwenden. < /P>
public class CompanyResolver
{
[UseOffsetPaging(IncludeTotalCount = true)]
[UseProjection]
[UseFiltering]
[UseSorting]
public IQueryable GetChildCompanies(CompanyDbContext dbContext, [Parent] Company company)
{
return dbContext.Companies
.Include(x => x.Sol)
.Include(x => x.Comp)
.Include(x => x.Ris)
.Where(x => x.ParentId == company.CompanyId);
}
}
< /code>
Ich möchte das Ergebnis der Middleware mit diesem Ansatz < /p>
transformieren.public class CompanyObjectType : ObjectType
{
protected override void Configure(IObjectTypeDescriptor descriptor)
{
descriptor.Field("childCompanies")
.Type()
.Use(next => async context =>
{
await next(context);
if (context.Result is CollectionSegment allApplied)
{
var service = context.Services.GetRequiredService();
var sourceData = allApplied.Items.ToList();
var mappedData = sourceData.Any() ? service.mapper.Map(sourceData) : null;
context.Result = mappedData;
}
})
.ResolveWith(x => x.GetChildCompanies(default!, default!));
}
}
< /code>
Wie im Code -Block zu sehen, möchte ich eine Sammlung von ChildCompany zurückgeben. Ausführung der folgenden Anfrage in Bananenkuchen -Pop -Konsole < /p>
jedochchildCompanies(skip: 0, take: 5) {
totalCount
items {
organizationTypeId
relationshipTypeId
statusComment
statusDate
statusTypeId
}
}
< /code>
Gibt die folgende Fehlermeldung zurück, obwohl sie Filterung, Sortierung usw. anwendet. < /p>
{
"message": "The resolver parent type of field `ChildCompaniesCollectionSegment.items` is `System.Collections.Generic.List`1[Eastdil.Companies.GraphQL.Types.ChildCompany]` but the resolver requested the type `HotChocolate.Types.Pagination.CollectionSegment`. The resolver was unable to cast the parent type to the requested type.",
"path": [
"company",
"childCompanies",
"items"
],
"extensions": {
"field": "ChildCompaniesCollectionSegment.items",
"code": "HC0053"
}
}
< /code>
Ich habe es versucht, ohne eine Middleware wie diese zu verwenden, aber die Abfrage filtert noch nicht. Bananenkuchen Pop zeigte keine Argumente. < /P>
descriptor.Field("childCompanies")
.Type()
.Resolve(async context =>
{
var allApplied = await query.Sort(context)
.Filter(context)
.Project(context)
.ApplyOffsetPaginationAsync(context);
...
...
});
[url=viewtopic.php?t=14917]Ich möchte[/url] ein benutzerdefiniertes Modell zurückgeben, nicht einen Sammelsegmenttyp. Dies ist mein Resolver, um Sortieren, Filtern, Pagination und Projektion anzuwenden. < /P> [code]public class CompanyResolver {
[UseOffsetPaging(IncludeTotalCount = true)] [UseProjection] [UseFiltering] [UseSorting] public IQueryable GetChildCompanies(CompanyDbContext dbContext, [Parent] Company company) { return dbContext.Companies .Include(x => x.Sol) .Include(x => x.Comp) .Include(x => x.Ris) .Where(x => x.ParentId == company.CompanyId); } } < /code> Ich möchte das Ergebnis der Middleware mit diesem Ansatz < /p> transformieren.public class CompanyObjectType : ObjectType { protected override void Configure(IObjectTypeDescriptor descriptor) { descriptor.Field("childCompanies") .Type() .Use(next => async context => { await next(context); if (context.Result is CollectionSegment allApplied) { var service = context.Services.GetRequiredService(); var sourceData = allApplied.Items.ToList(); var mappedData = sourceData.Any() ? service.mapper.Map(sourceData) : null; context.Result = mappedData; } }) .ResolveWith(x => x.GetChildCompanies(default!, default!)); } } < /code> Wie im Code -Block zu sehen, möchte ich eine Sammlung von ChildCompany zurückgeben. Ausführung der folgenden Anfrage in Bananenkuchen -Pop -Konsole < /p> jedochchildCompanies(skip: 0, take: 5) { totalCount items { organizationTypeId relationshipTypeId statusComment statusDate statusTypeId } } < /code> Gibt die folgende Fehlermeldung zurück, obwohl sie Filterung, Sortierung usw. anwendet. < /p> { "message": "The resolver parent type of field `ChildCompaniesCollectionSegment.items` is `System.Collections.Generic.List`1[Eastdil.Companies.GraphQL.Types.ChildCompany]` but the resolver requested the type `HotChocolate.Types.Pagination.CollectionSegment`. The resolver was unable to cast the parent type to the requested type.", "path": [ "company", "childCompanies", "items" ], "extensions": { "field": "ChildCompaniesCollectionSegment.items", "code": "HC0053" } } < /code> Ich habe es versucht, ohne eine Middleware wie diese zu verwenden, aber die Abfrage filtert noch nicht. Bananenkuchen Pop zeigte keine Argumente. < /P> descriptor.Field("childCompanies") .Type() .Resolve(async context => { var allApplied = await query.Sort(context) .Filter(context) .Project(context) .ApplyOffsetPaginationAsync(context); ... ... }); [/code] Bitte lassen Sie mich wissen, was mir hier fehlt
Ich habe eine einfache Pyflink -Anwendung, in der ich einen Primärschlüssel für die temporale Tabellenverbindung benötige. Da meine Quelle Avro Confluent -Format verwendet und Probleme mit...
Ich muss ein äquirektangulares Bild in ein anderes gleichmäßiges Bild mit einer 90 ° -Rolle verwandeln. Ich kann also keine G.U.I. Dazu orientierte ich meine Forschung zu Imagemagick . Ich habe die...
Pythons PIL -Modul (Python -Kissen) Ich versuche, ein Bild 85 Pixel mit einer affine Transformation nach rechts zu verschieben. Der folgende Code sollte dazu, aber stattdessen verschiebt das Bild...