Comments (18)
Navigation properties are selectively included.
for non-navigation properties you can explicitly select what properties to include
AddQueryField<EmployeeGraph, Employee>(
name: "employees",
resolve: context =>
{
var dataContext = (MyDataContext) context.UserContext;
return dataContext.Employees
.Select(x => new Employee {FirstName = x.FirstName});
});
Ideally in the future the non-navigation properties would also be selectively included based on the requested fields on the incoming graph
from graphql.entityframework.
super nice for navigation properties (AddNavigationField)
Why is it hard to extend this to the root query (AddQueryField) ?
from graphql.entityframework.
Why is it hard to extend this to the root query (AddQueryField) ?
because this
.Select(x => new Employee {FirstName = x.FirstName});
needs to be dynamically constructed. have a look here for the type of code that needs to be written https://github.com/SimonCropp/GraphQL.EntityFramework/blob/master/GraphQL.EntityFramework/Where/ExpressionBuilder.cs
from graphql.entityframework.
@SimonCropp i have a navigationField on Customer :
AddNavigationField<AddressGraph, Address>(
name: "address",
resolve: context => context.Source.Address);
And i still see all the Address fields in the sql query, although i only want Id in the request query
from graphql.entityframework.
@flieks happy to accept a PR that fixes that
from graphql.entityframework.
@SimonCropp It's possible for Scalar to know which fields to Select on the DBSet so we are interested in implementing this.
But what what about resolvers that want to use data from a Child (navigation) object and then return a StringGraphType for example? Or combine multiple tables to return something.
Should we implement an attribute on the Field<> to indicate which types to Include because the desired include isn't applied now?
And we could also give property names to the same attribute indicating which fields of that type we need for Select()
What do you suggest?
from graphql.entityframework.
But what what about resolvers that want to use data from a Child (navigation) object and then return a StringGraphType for example? Or combine multiple tables to return something.
do you currently have that use case? if not i would ignore it for now
from graphql.entityframework.
@SimonCropp yes we have that for many use cases ;).
For example a simple one:
return Quotes.Where(q => q.WonQuote).Sum(q => q.Price)
That should only fetch WonDeal & Price fields of the include
Or even more ideally would do the Where & Sum inside the Linq to Sql Query.
More thoughts:
So now only the main Query have to return DBSets where the subGraph's resolvers have already the executed data which means applying sum & where.
Maybe there's a possibility to return some kind of Expression Type so it can be catched and included in the initial main DBSet linq query.
Do you think it's possible ?
from graphql.entityframework.
Yep i think its possible
from graphql.entityframework.
Interesting, i will check it in a week when i have some time
from graphql.entityframework.
Will close this for now. Happy to reopen if someone want to work on it
from graphql.entityframework.
Hi @SimonCropp
Are select (projections) implemented already ?
Will query
query {
data {
id,
name
}
}
execute as
Select id, name from data
without all other fields in data table ?
Regards.
from graphql.entityframework.
@sebitsi yes but not as defined in the description above
from graphql.entityframework.
@SimonCropp Thanks for your response.
What do you mean by
yes but not as defined in the description above
Can you please explain more or point me to documentation.
If yes, how it works and what i have to do ?
Regards.
from graphql.entityframework.
@sebitsi you can read about defining graphs here https://github.com/SimonCropp/GraphQL.EntityFramework/blob/master/doco/defining-graphs.md and there is a runnable sample here https://github.com/SimonCropp/GraphQL.EntityFramework/tree/master/src/SampleWeb
BTW if you intending on using the project you should note that it is required that you become a backer https://github.com/SimonCropp/GraphQL.EntityFramework#community-backed
from graphql.entityframework.
Hi @SimonCropp.
-
I read all contents in links you provide.
There is no answere how library handles LINQ select on subFields.
I think library cannot handle scenario as i wrote.
Please tell how if this is not correct. -
AddQueryfield is not working as expected.
From my code:
public CountryGraph(IEfGraphQLService<CommonDbContext> graphQlService) : base(graphQlService)
{
Field(x => x.Id);
Field(x => x.Name);
Field(x => x.Code);
AddQueryField(
name: "postoffices",
resolve: context => context.DbContext.Posts.Where(p => p.CountryID == context.Source.Id)
) ;
}
This config returns data, but there is n + 1 query generated in sql.
One for all countries and n for each postofice:
Select * From Country
Select * From PostOffice Where CountryID = 1
Select * From PostOffice Where CountryID = 2
Select * From PostOffice Where CountryID = 3
etc
Is there an error in my configuration or library cannot handle it.
Please advice.
-
I will become baker if i decide to use library, Before that i need to know what library can handle and what not.
-
Do you have some roadmap about features i noticed not working ?
from graphql.entityframework.
sorry. in the form you want it is not supported. no there is no current plan to add that
from graphql.entityframework.
I'm sorry to hear that,
This library has potential.
But without this features and no roadmap i'm affraid cannot choose it for our project.
Thanks for your time.
from graphql.entityframework.
Related Issues (20)
- How to run comparisons with GraphQL.EF lib HOT 1
- Can't register some classes into Autofac container HOT 2
- Documentation Request: Describe function behavior HOT 1
- Improvement: supporting contributions through more maintainable code HOT 3
- Remove AND + OR from Connector
- remove `Graph` suffic from build in graphs
- Putting 'where' on a sub graph doesn't evaluate at db HOT 14
- KeyNameExtractor creates collisions with many-to-many relationship HOT 1
- Quotes no longer required around where properties HOT 2
- Is it possible to use it for working without EF? HOT 3
- Add support for owned entities
- Make connection non nullable
- Fix SetField order
- 'Case' in where clause is throwing an error HOT 3
- Update to EF 6
- RegisterInContainer and Entity will have errors in different assembly HOT 2
- NO SCHEMA AVAILABLE HOT 1
- drop screaming caps from StringComparisonGraph
- nullable option to nav field
- Nullability Unknown for non-nullable context HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql.entityframework.