Git Product home page Git Product logo

Comments (18)

SimonCropp avatar SimonCropp commented on May 12, 2024

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.

flieks avatar flieks commented on May 12, 2024

super nice for navigation properties (AddNavigationField)
Why is it hard to extend this to the root query (AddQueryField) ?

from graphql.entityframework.

SimonCropp avatar SimonCropp commented on May 12, 2024

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.

flieks avatar flieks commented on May 12, 2024

@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.

SimonCropp avatar SimonCropp commented on May 12, 2024

@flieks happy to accept a PR that fixes that

from graphql.entityframework.

flieks avatar flieks commented on May 12, 2024

@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.

SimonCropp avatar SimonCropp commented on May 12, 2024

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.

flieks avatar flieks commented on May 12, 2024

@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.

SimonCropp avatar SimonCropp commented on May 12, 2024

Yep i think its possible

from graphql.entityframework.

flieks avatar flieks commented on May 12, 2024

Interesting, i will check it in a week when i have some time

from graphql.entityframework.

SimonCropp avatar SimonCropp commented on May 12, 2024

Will close this for now. Happy to reopen if someone want to work on it

from graphql.entityframework.

sebitsi avatar sebitsi commented on May 12, 2024

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.

SimonCropp avatar SimonCropp commented on May 12, 2024

@sebitsi yes but not as defined in the description above

from graphql.entityframework.

sebitsi avatar sebitsi commented on May 12, 2024

@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.

SimonCropp avatar SimonCropp commented on May 12, 2024

@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.

sebitsi avatar sebitsi commented on May 12, 2024

Hi @SimonCropp.

  1. 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.

  2. 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.

  1. I will become baker if i decide to use library, Before that i need to know what library can handle and what not.

  2. Do you have some roadmap about features i noticed not working ?

from graphql.entityframework.

SimonCropp avatar SimonCropp commented on May 12, 2024

sorry. in the form you want it is not supported. no there is no current plan to add that

from graphql.entityframework.

sebitsi avatar sebitsi commented on May 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.