Skip to content

Commit

Permalink
Implements hacky, temporary solution to #13
Browse files Browse the repository at this point in the history
  • Loading branch information
anpete committed Mar 18, 2016
1 parent d3f7abe commit 669b8a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
28 changes: 14 additions & 14 deletions src/GrefQL/Query/FieldResolverFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,21 +331,21 @@ private static IQueryable<TEntity> ApplyProjection<TEntity>(
var entityParameterExpression = Expression.Parameter(entityClrType, "entity");
var memberAssignments = new List<MemberAssignment>();

foreach (var selection in selectionSet)
foreach (var property
in selectionSet
.Select(s => entityType.FindProperty(s.Field.Name.ToPascalCase()))
.Where(p => p != null)
.Union(entityType.GetKeys().SelectMany(k => k.Properties))
.Union(entityType.GetForeignKeys().SelectMany(fk => fk.Properties)))
{
var property = entityType.FindProperty(selection.Field.Name.ToPascalCase());

if (property != null)
{
memberAssignments.Add(
Expression.Bind(
entityTypeInfo.GetProperty(property.Name),
Expression.Call(
null,
_efPropertyMethodInfo.MakeGenericMethod(property.ClrType),
entityParameterExpression,
Expression.Constant(property.Name))));
}
memberAssignments.Add(
Expression.Bind(
entityTypeInfo.GetProperty(property.Name),
Expression.Call(
null,
_efPropertyMethodInfo.MakeGenericMethod(property.ClrType),
entityParameterExpression,
Expression.Constant(property.Name))));
}

var selector
Expand Down
1 change: 0 additions & 1 deletion test/GrefQL.Tests/ConcurrentQueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public void It_doesnt_throw_concurrency_error()
phone
orders {
orderId
customerId
customer {
customerId
}
Expand Down
2 changes: 0 additions & 2 deletions test/GrefQL.Tests/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ public void Query_orders_with_customer()
{
orders(limit: 2) {
orderId
customerId
customer {
customerId
contactName
}
}
Expand Down

0 comments on commit 669b8a0

Please sign in to comment.