// Transform db => db.Entities.Where(args) into args => db => db.Entities.Where(args) public static GraphQLFieldBuilder <TContext, TEntity> AddField <TContext, TEntity>(this GraphQLSchema <TContext> context, string name, Expression <Func <TContext, TEntity> > queryableGetter) { var info = GetQueryInfo(queryableGetter); if (info.ResolutionType != ResolutionType.Unmodified) { return(context.AddFieldInternal(name, GetFinalQueryFunc <TContext, object, IEnumerable <TEntity> >(info.BaseQuery), info.ResolutionType)); } return(context.AddUnmodifiedFieldInternal(name, GetFinalQueryFunc <TContext, object, TEntity>(info.OriginalQuery))); }
// Transform (db, args) => db.Entities.First(args) into args => db => db.Entities.First(args) private static GraphQLFieldBuilder <TContext, TEntity> AddField <TContext, TArgs, TEntity>(this GraphQLSchema <TContext> context, string name, Expression <Func <TContext, TArgs, TEntity> > queryableGetter) { var innerLambda = Expression.Lambda <Func <TContext, TEntity> >(queryableGetter.Body, queryableGetter.Parameters[0]); var info = GetQueryInfo(innerLambda); if (info.ResolutionType != ResolutionType.Unmodified) { return(context.AddFieldInternal(name, GetFinalQueryFunc <TContext, TArgs, IEnumerable <TEntity> >(info.BaseQuery, queryableGetter.Parameters[1]), info.ResolutionType)); } return(context.AddUnmodifiedFieldInternal(name, GetFinalQueryFunc <TContext, TArgs, TEntity>(info.OriginalQuery, queryableGetter.Parameters[1]))); }
// Transform (db, args) => db.Entities.Where(args) into args => db => db.Entities.Where(args) private static GraphQLFieldBuilder <TContext, TEntity> AddListField <TContext, TArgs, TEntity>(this GraphQLSchema <TContext> context, string name, Expression <Func <TContext, TArgs, IEnumerable <TEntity> > > queryableGetter) { var innerLambda = Expression.Lambda <Func <TContext, IEnumerable <TEntity> > >(queryableGetter.Body, queryableGetter.Parameters[0]); return(context.AddFieldInternal(name, GetFinalQueryFunc <TContext, TArgs, IEnumerable <TEntity> >(innerLambda, queryableGetter.Parameters[1]), ResolutionType.ToList)); }
// Transform db => db.Entities.Where(args) into args => db => db.Entities.Where(args) public static GraphQLFieldBuilder <TContext, TEntity> AddListField <TContext, TEntity>( this GraphQLSchema <TContext> context, string name, Expression <Func <TContext, IEnumerable <TEntity> > > queryableGetter) { return(context.AddFieldInternal(name, GetFinalQueryFunc <TContext, object, IEnumerable <TEntity> >(queryableGetter), ResolutionType.ToList)); }