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
Copy file name to clipboardExpand all lines: src/GraphQL.EntityFramework.Analyzers/DiagnosticDescriptors.cs
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,14 @@ static class DiagnosticDescriptors
9
9
isEnabledByDefault:true,
10
10
description:"When using Field().Resolve() or Field().ResolveAsync() inside EfObjectGraphType, EfInterfaceGraphType, or QueryGraphType classes, navigation properties on context.Source may not be loaded due to EF projection. Use the projection-based extension methods (Resolve<TDbContext, TSource, TReturn, TProjection>, ResolveAsync<TDbContext, TSource, TReturn, TProjection>, etc.) to ensure required data is loaded.",
title:"Identity projection is not allowed in projection-based Resolve methods",
16
+
messageFormat:"Identity projection '_ => _' defeats the purpose of projection-based Resolve. Use regular Resolve() method for PK/FK access, or specify navigation properties in projection.",
17
+
category:"Usage",
18
+
defaultSeverity:DiagnosticSeverity.Error,
19
+
isEnabledByDefault:true,
20
+
description:"Using '_ => _' as the projection parameter in projection-based Resolve extension methods is not allowed because it doesn't load any additional navigation properties. If you only need to access primary key or foreign key properties, use the regular Resolve() method instead. If you need to access navigation properties, specify them in the projection (e.g., 'x => x.Parent').",
if(projection.Bodyis not ParameterExpressionparameter||
385
+
parameter!=projection.Parameters[0])
386
+
{
387
+
return;
388
+
}
389
+
390
+
thrownewArgumentException(
391
+
"Identity projection '_ => _' is not allowed. If only access to primary key or foreign key properties, use the regular Resolve() method instead. If required to access navigation properties, specify them in the projection (e.g., '_ => _.Parent').",
0 commit comments